Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
16aad72a
Commit
16aad72a
authored
Aug 10, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable PEP-489 module initialisation again, but raise an error on re-inits.
parent
c9b36210
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+7
-5
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+1
-3
No files found.
Cython/Compiler/ModuleNode.py
View file @
16aad72a
...
...
@@ -2326,11 +2326,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
put_declare_refcount_context
()
code
.
putln
(
"#if CYTHON_PEP489_MULTI_PHASE_INIT"
)
# Hack: enforce single initialisation.
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 has already been imported. Re-initialisation is not supported");'
)
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);"
%
(
...
...
Cython/Utility/ModuleSetupCode.c
View file @
16aad72a
...
...
@@ -178,9 +178,7 @@
#define CYTHON_FAST_PYCALL 1
#endif
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
// 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)
#define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
#endif
#ifndef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment