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
a86c19f1
Commit
a86c19f1
authored
Dec 31, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
warn about unreachable except-else clause
--HG-- extra : amend_source : 4c6b14a416f49c6942dc5fafc87b1ea2120bac7b
parent
08077345
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+3
-1
tests/errors/w_unreachable.pyx
tests/errors/w_unreachable.pyx
+10
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
a86c19f1
...
...
@@ -2164,7 +2164,9 @@ class RemoveUnreachableCode(CythonTransform):
def
visit_TryExceptStatNode
(
self
,
node
):
self
.
visitchildren
(
node
)
if
node
.
body
.
is_terminator
:
if
node
.
body
.
is_terminator
and
node
.
else_clause
:
if
self
.
current_directives
[
'warn.unreachable'
]:
warning
(
node
.
else_clause
.
pos
,
"Unreachable code"
,
2
)
node
.
else_clause
=
None
return
node
...
...
tests/errors/w_unreachable.pyx
View file @
a86c19f1
...
...
@@ -23,9 +23,19 @@ def conditional(a, b):
return
3
print
'oops'
def
try_except
():
try
:
raise
TypeError
except
ValueError
:
pass
else
:
print
'unreachable'
_ERRORS
=
"""
6:4: Unreachable code
11:8: Unreachable code
15:8: Unreachable code
24:4: Unreachable code
32:8: Unreachable code
"""
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