Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
994ab164
Commit
994ab164
authored
Dec 13, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pop the loop block even for infinite while loops (closes #23048)
parent
824a02c0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
6 deletions
+19
-6
Lib/test/test_dis.py
Lib/test/test_dis.py
+4
-3
Lib/test/test_sys_settrace.py
Lib/test/test_sys_settrace.py
+11
-0
Misc/NEWS
Misc/NEWS
+2
-0
Python/compile.c
Python/compile.c
+2
-3
No files found.
Lib/test/test_dis.py
View file @
994ab164
...
...
@@ -178,15 +178,16 @@ dis_compound_stmt_str = """\
1 0 LOAD_CONST 0 (0)
3 STORE_NAME 0 (x)
2 6 SETUP_LOOP 1
3 (to 22
)
2 6 SETUP_LOOP 1
4 (to 23
)
3 >> 9 LOAD_NAME 0 (x)
12 LOAD_CONST 1 (1)
15 INPLACE_ADD
16 STORE_NAME 0 (x)
19 JUMP_ABSOLUTE 9
>> 22 LOAD_CONST 2 (None)
25 RETURN_VALUE
22 POP_BLOCK
>> 23 LOAD_CONST 2 (None)
26 RETURN_VALUE
"""
dis_traceback
=
"""
\
...
...
Lib/test/test_sys_settrace.py
View file @
994ab164
...
...
@@ -579,6 +579,15 @@ def jump_in_nested_finally(output):
jump_in_nested_finally
.
jump
=
(
4
,
9
)
jump_in_nested_finally
.
output
=
[
2
,
9
]
def
jump_infinite_while_loop
(
output
):
output
.
append
(
1
)
while
1
:
output
.
append
(
2
)
output
.
append
(
3
)
jump_infinite_while_loop
.
jump
=
(
3
,
4
)
jump_infinite_while_loop
.
output
=
[
1
,
3
]
# The second set of 'jump' tests are for things that are not allowed:
def
no_jump_too_far_forwards
(
output
):
...
...
@@ -755,6 +764,8 @@ class JumpTestCase(unittest.TestCase):
self
.
run_test
(
jump_to_same_line
)
def
test_07_jump_in_nested_finally
(
self
):
self
.
run_test
(
jump_in_nested_finally
)
def
test_jump_infinite_while_loop
(
self
):
self
.
run_test
(
jump_infinite_while_loop
)
def
test_08_no_jump_too_far_forwards
(
self
):
self
.
run_test
(
no_jump_too_far_forwards
)
def
test_09_no_jump_too_far_backwards
(
self
):
...
...
Misc/NEWS
View file @
994ab164
...
...
@@ -11,6 +11,8 @@ Release date: TBA
Core and Builtins
-----------------
- Issue #23048: Fix jumping out of an infinite while loop in the pdb.
- Issue #20335: bytes constructor now raises TypeError when encoding or errors
is specified with non-string argument. Based on patch by Renaud Blanch.
...
...
Python/compile.c
View file @
994ab164
...
...
@@ -2029,10 +2029,9 @@ compiler_while(struct compiler *c, stmt_ty s)
if there is no else clause ?
*/
if
(
constant
==
-
1
)
{
if
(
constant
==
-
1
)
compiler_use_next_block
(
c
,
anchor
);
ADDOP
(
c
,
POP_BLOCK
);
}
ADDOP
(
c
,
POP_BLOCK
);
compiler_pop_fblock
(
c
,
LOOP
,
loop
);
if
(
orelse
!=
NULL
)
/* what if orelse is just pass? */
VISIT_SEQ
(
c
,
stmt
,
s
->
v
.
While
.
orelse
);
...
...
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