Commit 429936a2 authored by Stefan Behnel's avatar Stefan Behnel

Revert PEP-489 behaviour, but keep error raising code to make it easy to try both.

parent 17d28b34
...@@ -2326,14 +2326,19 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2326,14 +2326,19 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.put_declare_refcount_context() code.put_declare_refcount_context()
code.putln("#if CYTHON_PEP489_MULTI_PHASE_INIT") code.putln("#if CYTHON_PEP489_MULTI_PHASE_INIT")
# Hack: enforce single initialisation. # Hack: enforce single initialisation.
# Most extension modules simply can't deal with it, and Cython isn't ready either. code.putln("if (%s && %s == %s) return 0;" % (
# See issues listed here: https://docs.python.org/3/c-api/init.html#sub-interpreter-support Naming.module_cname,
code.putln("if (%s) {" % Naming.module_cname) Naming.module_cname,
code.putln('PyErr_SetString(PyExc_RuntimeError,' Naming.pymodinit_module_arg,
' "Module \'%s\' has already been imported. Re-initialisation is not supported");' % ))
env.module_name) # # Most extension modules simply can't deal with it, and Cython isn't ready either.
code.putln("return -1;") # # See issues listed here: https://docs.python.org/3/c-api/init.html#sub-interpreter-support
code.putln("}") # code.putln("if (%s) {" % Naming.module_cname)
# code.putln('PyErr_SetString(PyExc_RuntimeError,'
# ' "Module \'%s\' has already been imported. Re-initialisation is not supported");' %
# env.module_name)
# code.putln("return -1;")
# code.putln("}")
code.putln("#elif PY_MAJOR_VERSION >= 3") code.putln("#elif PY_MAJOR_VERSION >= 3")
# Hack: enforce single initialisation also on reimports under different names on Python 3 (with PEP 3121/489). # Hack: enforce single initialisation also on reimports under different names on Python 3 (with PEP 3121/489).
code.putln("if (%s) return __Pyx_NewRef(%s);" % ( code.putln("if (%s) return __Pyx_NewRef(%s);" % (
......
...@@ -178,7 +178,9 @@ ...@@ -178,7 +178,9 @@
#define CYTHON_FAST_PYCALL 1 #define CYTHON_FAST_PYCALL 1
#endif #endif
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) // Disabled for now. Most extension modules simply can't deal with it, and Cython isn't ready either.
// See issues listed here: https://docs.python.org/3/c-api/init.html#sub-interpreter-support
#define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
#endif #endif
#ifndef CYTHON_USE_TP_FINALIZE #ifndef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment