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
Kirill Smelkov
cython
Commits
a4e9888c
Commit
a4e9888c
authored
Sep 27, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enforce single module initialisation despite PEP 489 allowing to re-execute a module.
parent
cf6935df
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
3 deletions
+17
-3
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+10
-1
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+4
-0
runtests.py
runtests.py
+0
-2
tests/bugs.txt
tests/bugs.txt
+3
-0
No files found.
Cython/Compiler/ModuleNode.py
View file @
a4e9888c
...
...
@@ -694,7 +694,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
put
(
Nodes
.
branch_prediction_macros
)
code
.
putln
(
'static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }'
)
code
.
putln
(
''
)
code
.
putln
(
'static PyObject *%s;'
%
env
.
module_cname
)
code
.
putln
(
'static PyObject *%s
= NULL
;'
%
env
.
module_cname
)
code
.
putln
(
'static PyObject *%s;'
%
env
.
module_dict_cname
)
code
.
putln
(
'static PyObject *%s;'
%
Naming
.
builtins_cname
)
code
.
putln
(
'static PyObject *%s;'
%
Naming
.
cython_runtime_cname
)
...
...
@@ -2274,6 +2274,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"Profile"
,
"Profile.c"
))
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
,
))
code
.
putln
(
"#endif"
)
if
profile
or
linetrace
:
tempdecl_code
.
put_trace_declarations
()
code
.
put_trace_frame_init
()
...
...
Cython/Utility/ModuleSetupCode.c
View file @
a4e9888c
...
...
@@ -753,6 +753,10 @@ static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const ch
static
PyObject
*
$
{
pymodule_create_func_cname
}(
PyObject
*
spec
,
CYTHON_UNUSED
PyModuleDef
*
def
)
{
PyObject
*
module
=
NULL
,
*
moddict
,
*
modname
;
// For now, we only have exactly one module instance.
if
(
$
{
module_cname
})
return
__Pyx_NewRef
({
module_cname
});
modname
=
PyObject_GetAttrString
(
spec
,
"name"
);
if
(
unlikely
(
!
modname
))
goto
bad
;
...
...
runtests.py
View file @
a4e9888c
...
...
@@ -350,8 +350,6 @@ VER_DEP_MODULES = {
'run.mod__spec__',
'run.pep526_variable_annotations', # typing module
]),
(99,): (operator.lt, lambda x: x in ['run.mod__spec__', # actually Py3.5, but currently disabled
]),
}
INCLUDE_DIRS = [ d for d in os.getenv('INCLUDE', '').split(os.pathsep) if d ]
...
...
tests/bugs.txt
View file @
a4e9888c
...
...
@@ -12,6 +12,9 @@ temp_sideeffects_T654 # not really a bug, Cython warns about it
inherited_final_method
cimport_alias_subclass
# PEP-489 is currently disabled
run.mod__spec__
# CPython regression tests that don't current work:
pyregr.test_signal
pyregr.test_capi
...
...
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