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
575eb02f
Commit
575eb02f
authored
7 years ago
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make "break" outside of loops a syntax error also inside of try-except blocks.
Closes #1726.
parent
7998f0af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-2
tests/errors/break_outside_loop.pyx
tests/errors/break_outside_loop.pyx
+21
-0
No files found.
Cython/Compiler/Nodes.py
View file @
575eb02f
...
...
@@ -5508,6 +5508,7 @@ class IndirectionNode(StatListNode):
def
__init__
(
self
,
stats
):
super
(
IndirectionNode
,
self
).
__init__
(
stats
[
0
].
pos
,
stats
=
stats
)
class
BreakStatNode
(
StatNode
):
child_attrs
=
[]
...
...
@@ -6684,8 +6685,8 @@ class TryExceptStatNode(StatNode):
except_error_label
=
code
.
new_label
(
'except_error'
)
except_return_label
=
code
.
new_label
(
'except_return'
)
try_return_label
=
code
.
new_label
(
'try_return'
)
try_break_label
=
code
.
new_label
(
'try_break'
)
try_continue_label
=
code
.
new_label
(
'try_continue'
)
try_break_label
=
code
.
new_label
(
'try_break'
)
if
old_break_label
else
None
try_continue_label
=
code
.
new_label
(
'try_continue'
)
if
old_continue_label
else
None
try_end_label
=
code
.
new_label
(
'try_end'
)
exc_save_vars
=
[
code
.
funcstate
.
allocate_temp
(
py_object_type
,
False
)
...
...
This diff is collapsed.
Click to expand it.
tests/errors/break_outside_loop.pyx
View file @
575eb02f
...
...
@@ -27,12 +27,33 @@ def bool_result():
return
True
def
break_after_loop
():
for
_
in
range
(
2
):
pass
if
bool_result
():
break
try
:
if
bool_result
():
break
except
Exception
:
pass
if
bool_result
():
break
_ERRORS
=
u'''
4:0: break statement not inside loop
7:4: break statement not inside loop
10:4: break statement not inside loop
13:4: break statement not inside loop
15:5: break statement not inside loop
18:5: break statement not inside loop
22:4: break statement not inside loop
24:4: break statement not inside loop
35:8: break statement not inside loop
39:12: break statement not inside loop
44:8: break statement not inside loop
'''
This diff is collapsed.
Click to expand it.
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