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
b4e58e0b
Commit
b4e58e0b
authored
Sep 18, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Noargs exec()
parent
05a561df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
2 deletions
+42
-2
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+11
-0
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+0
-2
tests/run/exec_noargs.pyx
tests/run/exec_noargs.pyx
+31
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
b4e58e0b
...
...
@@ -2250,6 +2250,17 @@ class TransformBuiltinMethods(EnvTransform):
error
(
node
.
pos
,
u"'%s' not a valid cython attribute or is being used incorrectly"
%
attribute
)
return
node
def
visit_ExecStatNode
(
self
,
node
):
lenv
=
self
.
current_env
()
self
.
visitchildren
(
node
)
if
len
(
node
.
args
)
==
1
:
node
.
args
.
append
(
ExprNodes
.
GlobalsExprNode
(
node
.
pos
))
if
not
lenv
.
is_module_scope
:
node
.
args
.
append
(
ExprNodes
.
LocalsExprNode
(
node
.
pos
,
self
.
current_scope_node
(),
lenv
))
return
node
def
_inject_locals
(
self
,
node
,
func_name
):
# locals()/dir()/vars() builtins
lenv
=
self
.
current_env
()
...
...
Cython/Compiler/Parsing.py
View file @
b4e58e0b
...
...
@@ -1124,8 +1124,6 @@ def p_exec_statement(s):
if
s
.
sy
==
','
:
s
.
next
()
args
.
append
(
p_test
(
s
))
else
:
error
(
pos
,
"'exec' currently requires a target mapping (globals/locals)"
)
return
Nodes
.
ExecStatNode
(
pos
,
args
=
args
)
def
p_del_statement
(
s
):
...
...
tests/run/exec_noargs.pyx
0 → 100644
View file @
b4e58e0b
# mode: run
# tags: exec
exec
"GLOBAL = 1234"
def
exec_module_scope
():
"""
>>> globals()['GLOBAL']
1234
"""
def
exec_func_scope
():
"""
>>> exec_func_scope()
{'a': 'b', 'G': 1234}
"""
d
=
{}
exec
"d['a'] = 'b'; d['G'] = GLOBAL"
return
d
def
exec_pyclass_scope
():
"""
>>> obj = exec_pyclass_scope()
>>> obj.a
'b'
>>> obj.G
1234
"""
class
TestExec
:
exec
"a = 'b'; G = GLOBAL"
return
TestExec
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