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
de698936
Commit
de698936
authored
Jul 26, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not evaluate DEF statements inside of IF blocks with false conditions.
Closes #1796
parent
0b0a2e57
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
3 deletions
+34
-3
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+4
-3
tests/run/ct_IF.pyx
tests/run/ct_IF.pyx
+30
-0
No files found.
Cython/Compiler/Parsing.py
View file @
de698936
...
...
@@ -2160,6 +2160,7 @@ def p_DEF_statement(s):
name
=
p_ident
(
s
)
s
.
expect
(
'='
)
expr
=
p_compile_time_expr
(
s
)
if
s
.
compile_time_eval
:
value
=
expr
.
compile_time_value
(
denv
)
#print "p_DEF_statement: %s = %r" % (name, value) ###
denv
.
declare
(
name
,
value
)
...
...
tests/run/ct_IF.pyx
View file @
de698936
...
...
@@ -42,3 +42,33 @@ def h():
ELSE
:
i
=
3
return
i
def
control_flow_DEF1
():
"""
>>> control_flow_DEF1()
B should be 2.
2
"""
IF
YES
:
DEF
B
=
2
print
(
'B should be 2.'
)
ELSE
:
DEF
B
=
3
print
(
'B should be 3.'
)
return
B
def
control_flow_DEF2
():
"""
>>> control_flow_DEF2()
B should be 3.
3
"""
IF
NO
:
DEF
B
=
2
print
(
'B should be 2.'
)
ELSE
:
DEF
B
=
3
print
(
'B should be 3.'
)
return
B
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