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
4d7fbe25
Commit
4d7fbe25
authored
Jul 27, 2016
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow old_style_globals to be set via a directive.
parent
2a581a2b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
6 deletions
+16
-6
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+4
-4
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+2
-0
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+5
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+5
-1
No files found.
Cython/Compiler/Builtin.py
View file @
4d7fbe25
...
...
@@ -208,12 +208,12 @@ builtin_function_table = [
# Put in namespace append optimization.
BuiltinFunction
(
'__Pyx_PyObject_Append'
,
"OO"
,
"O"
,
"__Pyx_PyObject_Append"
),
# This is conditionally looked up based on a compiler directive.
BuiltinFunction
(
'__Pyx_globals'
,
""
,
"O"
,
"__Pyx_Globals"
,
utility_code
=
globals_utility_code
),
]
if
not
Options
.
old_style_globals
:
builtin_function_table
.
append
(
BuiltinFunction
(
'globals'
,
""
,
"O"
,
"__Pyx_Globals"
,
utility_code
=
globals_utility_code
))
# Builtin types
# bool
...
...
Cython/Compiler/ModuleNode.py
View file @
4d7fbe25
...
...
@@ -103,6 +103,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
scope
.
merge_in
(
scope
)
def
analyse_declarations
(
self
,
env
):
if
self
.
directives
:
env
.
old_style_globals
=
self
.
directives
[
'old_style_globals'
]
if
not
Options
.
docstrings
:
env
.
doc
=
self
.
doc
=
None
elif
Options
.
embed_pos_in_docstring
:
...
...
Cython/Compiler/Options.py
View file @
4d7fbe25
...
...
@@ -106,7 +106,7 @@ embed = None
# In previous iterations of Cython, globals() gave the first non-Cython module
# globals in the call stack. Sage relies on this behavior for variable injection.
old_style_globals
=
False
old_style_globals
=
ShouldBeFromDirective
(
'old_style_globals'
)
# Allows cimporting from a pyx file without a pxd file.
cimport_from_pyx
=
False
...
...
@@ -173,6 +173,7 @@ _directive_defaults = {
'c_string_encoding'
:
''
,
'type_version_tag'
:
True
,
# enables Py_TPFLAGS_HAVE_VERSION_TAG on extension types
'unraisable_tracebacks'
:
False
,
'old_style_globals'
:
False
,
# set __file__ and/or __path__ to known source/target path at import time (instead of not having them available)
'set_initial_path'
:
None
,
# SOURCEFILE or "/full/path/to/module"
...
...
@@ -304,6 +305,9 @@ directive_scopes = { # defaults to available everywhere
'c_string_encoding'
:
(
'module'
,),
'type_version_tag'
:
(
'module'
,
'cclass'
),
'language_level'
:
(
'module'
,),
# globals() could conceivably be controlled at a finer granularity,
# but that would complicate the implementation
'old_style_globals'
:
(
'module'
,),
}
...
...
Cython/Compiler/Symtab.py
View file @
4d7fbe25
...
...
@@ -1034,6 +1034,7 @@ class ModuleScope(Scope):
is_module_scope
=
1
has_import_star
=
0
is_cython_builtin
=
0
old_style_globals
=
0
def
__init__
(
self
,
name
,
parent_module
,
context
):
from
.
import
Builtin
...
...
@@ -1128,6 +1129,9 @@ class ModuleScope(Scope):
for
entry
in
self
.
cached_builtins
:
if
entry
.
name
==
name
:
return
entry
if
name
==
'globals'
and
not
self
.
old_style_globals
:
return
self
.
outer_scope
.
lookup
(
'__Pyx_globals'
)
else
:
entry
=
self
.
declare
(
None
,
None
,
py_object_type
,
pos
,
'private'
)
if
Options
.
cache_builtins
and
name
not
in
Code
.
uncachable_builtins
:
entry
.
is_builtin
=
1
...
...
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