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
12410403
Commit
12410403
authored
Jan 26, 2014
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CF: Fix try/except, try/finally bug
parent
795c0632
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
2 deletions
+42
-2
Cython/Compiler/FlowControl.py
Cython/Compiler/FlowControl.py
+2
-0
tests/memoryview/memoryview.pyx
tests/memoryview/memoryview.pyx
+6
-2
tests/run/uninitialized.py
tests/run/uninitialized.py
+34
-0
No files found.
Cython/Compiler/FlowControl.py
View file @
12410403
...
@@ -1121,6 +1121,7 @@ class ControlFlowAnalysis(CythonTransform):
...
@@ -1121,6 +1121,7 @@ class ControlFlowAnalysis(CythonTransform):
## XXX: links to exception handling point should be added by
## XXX: links to exception handling point should be added by
## XXX: children nodes
## XXX: children nodes
self
.
flow
.
block
.
add_child
(
entry_point
)
self
.
flow
.
block
.
add_child
(
entry_point
)
self
.
flow
.
nextblock
()
self
.
_visit
(
node
.
body
)
self
.
_visit
(
node
.
body
)
self
.
flow
.
exceptions
.
pop
()
self
.
flow
.
exceptions
.
pop
()
...
@@ -1181,6 +1182,7 @@ class ControlFlowAnalysis(CythonTransform):
...
@@ -1181,6 +1182,7 @@ class ControlFlowAnalysis(CythonTransform):
self
.
flow
.
block
=
body_block
self
.
flow
.
block
=
body_block
## XXX: Is it still required
## XXX: Is it still required
body_block
.
add_child
(
entry_point
)
body_block
.
add_child
(
entry_point
)
self
.
flow
.
nextblock
()
self
.
_visit
(
node
.
body
)
self
.
_visit
(
node
.
body
)
self
.
flow
.
exceptions
.
pop
()
self
.
flow
.
exceptions
.
pop
()
if
self
.
flow
.
loops
:
if
self
.
flow
.
loops
:
...
...
tests/memoryview/memoryview.pyx
View file @
12410403
...
@@ -175,6 +175,7 @@ def test_cdef_attribute():
...
@@ -175,6 +175,7 @@ def test_cdef_attribute():
>>> test_cdef_attribute()
>>> test_cdef_attribute()
Memoryview is not initialized
Memoryview is not initialized
local variable 'myview' referenced before assignment
local variable 'myview' referenced before assignment
local variable 'myview' referenced before assignment
get_ext_obj called
get_ext_obj called
Memoryview is not initialized
Memoryview is not initialized
<MemoryView of 'array' object>
<MemoryView of 'array' object>
...
@@ -195,8 +196,11 @@ def test_cdef_attribute():
...
@@ -195,8 +196,11 @@ def test_cdef_attribute():
else
:
else
:
print
"No UnboundLocalError was raised"
print
"No UnboundLocalError was raised"
# uninitialized assignment is valid
cdef
int
[:]
otherview
cdef
int
[:]
otherview
=
myview
try
:
otherview
=
myview
except
UnboundLocalError
,
e
:
print
e
.
args
[
0
]
try
:
try
:
print
get_ext_obj
().
mview
print
get_ext_obj
().
mview
...
...
tests/run/uninitialized.py
View file @
12410403
...
@@ -129,3 +129,37 @@ def test_class(cond):
...
@@ -129,3 +129,37 @@ def test_class(cond):
class
A
:
class
A
:
x
=
1
x
=
1
return
A
.
x
return
A
.
x
def
test_try_except_regression
(
c
):
"""
>>> test_try_except_regression(True)
(123,)
>>> test_try_except_regression(False)
Traceback (most recent call last):
...
UnboundLocalError: local variable 'a' referenced before assignment
"""
if
c
:
a
=
(
123
,)
try
:
return
a
except
:
return
a
def
test_try_finally_regression
(
c
):
"""
>>> test_try_finally_regression(True)
(123,)
>>> test_try_finally_regression(False)
Traceback (most recent call last):
...
UnboundLocalError: local variable 'a' referenced before assignment
"""
if
c
:
a
=
(
123
,)
try
:
return
a
finally
:
return
a
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