Skip to content

Commit c19fca7

Browse files
committed
Fix bug where inputsplitter could enter an infinite loop.
1 parent 3e7dca2 commit c19fca7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎IPython/core/inputsplitter.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ def split_blocks(self, lines):
384384
lines = lines.splitlines()[::-1]
385385
# Outer loop over all input
386386
while lines:
387+
#print 'Current lines:', lines # dbg
387388
# Inner loop to build each block
388389
while True:
389390
# Safety exit from inner loop
@@ -413,8 +414,10 @@ def split_blocks(self, lines):
413414
# dedent happens, so , we consume the line and we can break out
414415
# to start a new block.
415416

416-
# Case 1, explicit dedent causes a break
417-
if _full_dedent and not next_line.startswith(' '):
417+
# Case 1, explicit dedent causes a break.
418+
# Note: check that we weren't on the very last line, else we'll
419+
# enter an infinite loop adding/removing the last line.
420+
if _full_dedent and lines and not next_line.startswith(' '):
418421
lines.append(next_line)
419422
break
420423

0 commit comments

Comments
 (0)