Commit c872937f authored by Stefan Behnel's avatar Stefan Behnel

Work around BPO-32973: CPython 3 can rerun the module PyInit function if the...

Work around BPO-32973: CPython 3 can rerun the module PyInit function if the extension module is re-imported under a different name.
https://bugs.python.org/issue32973
parent 40d2c834
...@@ -2322,6 +2322,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2322,6 +2322,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
Naming.module_cname, Naming.module_cname,
Naming.pymodinit_module_arg, Naming.pymodinit_module_arg,
)) ))
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);" % (
Naming.module_cname,
Naming.module_cname,
))
code.putln("#endif") code.putln("#endif")
if profile or linetrace: if profile or linetrace:
......
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