summaryrefslogtreecommitdiff
path: root/Cython/Compiler/ModuleNode.py
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2018-08-10 17:57:30 +0200
committerStefan Behnel <stefan_ml@behnel.de>2018-08-10 17:57:30 +0200
commit429936a2d90648b64084c80deb7bda96b434b61d (patch)
tree335c27e19710a05715a3f6fbda25097e762a67d0 /Cython/Compiler/ModuleNode.py
parent17d28b3454d7595f86f01303d8fad369bc83b887 (diff)
downloadcython-429936a2d90648b64084c80deb7bda96b434b61d.tar.gz
Revert PEP-489 behaviour, but keep error raising code to make it easy to try both.
Diffstat (limited to 'Cython/Compiler/ModuleNode.py')
-rw-r--r--Cython/Compiler/ModuleNode.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py
index b6ce96996..6f4ff6b3b 100644
--- a/Cython/Compiler/ModuleNode.py
+++ b/Cython/Compiler/ModuleNode.py
@@ -2326,14 +2326,19 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.put_declare_refcount_context()
code.putln("#if CYTHON_PEP489_MULTI_PHASE_INIT")
# Hack: enforce single initialisation.
- # 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
- 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("if (%s && %s == %s) return 0;" % (
+ Naming.module_cname,
+ Naming.module_cname,
+ Naming.pymodinit_module_arg,
+ ))
+ # # 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
+ # 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")
# 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);" % (