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
f49d1f6f
Commit
f49d1f6f
authored
Jan 26, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable broken optimisation for except-as special case
parent
9ce870cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-5
tests/run/tryexcept.pyx
tests/run/tryexcept.pyx
+16
-0
No files found.
Cython/Compiler/Nodes.py
View file @
f49d1f6f
...
...
@@ -6093,14 +6093,10 @@ class ExceptClauseNode(Node):
if
(
not
getattr
(
self
.
body
,
'stats'
,
True
)
and
self
.
excinfo_target
is
None
and
(
self
.
target
is
None
or
self
.
is_except_as
)
):
and
self
.
target
is
None
):
# most simple case: no exception variable, empty body (pass)
# => reset the exception state, done
code
.
putln
(
"PyErr_Restore(0,0,0);"
)
if
self
.
is_except_as
and
self
.
target
:
# "except ... as x" deletes x after use
# target is known to be a NameNode
self
.
target
.
generate_deletion_code
(
code
)
code
.
put_goto
(
end_label
)
code
.
putln
(
"}"
)
return
...
...
tests/run/tryexcept.pyx
View file @
f49d1f6f
...
...
@@ -384,6 +384,22 @@ def except_as_raise_deletes_target(x, a):
print
(
b
)
# raises UnboundLocalError if except clause was executed
return
i
def
except_as_raise_with_empty_except
(
x
,
a
):
"""
>>> except_as_raise_with_empty_except(None, TypeError)
>>> except_as_raise_with_empty_except(TypeError('test'), TypeError)
>>> except_as_raise_with_empty_except(ValueError('test'), TypeError)
Traceback (most recent call last):
ValueError: test
>>> except_as_raise_with_empty_except(None, TypeError)
"""
try
:
if
x
:
raise
x
b
=
1
except
a
as
b
:
# previously raised UnboundLocalError
pass
def
except_as_deletes_target_in_gen
(
x
,
a
):
"""
>>> list(except_as_deletes_target_in_gen(None, TypeError))
...
...
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