Skip to content
Browse files

ensure ast.parse() gets code that ends with a newline

also fix an issue where irunner could send last newline after child exits, raising OSError

closes gh-409
closes gh-424
  • Loading branch information...
1 parent 6ba082e commit 429dac26c69cf9e35a13cf76b1ad0a4f9f809863 @minrk committed May 11, 2011
Showing with 3 additions and 2 deletions.
  1. +1 −1 IPython/core/interactiveshell.py
  2. +2 −1 IPython/lib/irunner.py
View
2 IPython/core/interactiveshell.py
@@ -2152,7 +2152,7 @@ def run_cell(self, raw_cell, store_history=True):
with self.display_trap:
try:
- code_ast = ast.parse(cell, filename=cell_name)
+ code_ast = ast.parse(cell+'\n', filename=cell_name)
except (OverflowError, SyntaxError, ValueError, TypeError,
MemoryError):
self.showsyntaxerror()
View
3 IPython/lib/irunner.py
@@ -263,7 +263,8 @@ def run_source(self,source,interact=False,get_output=False):
# Leave the child ready for more input later on, otherwise select just
# hangs on the second invocation.
- c.send('\n')
+ if c.isalive():
+ c.send('\n')
# Return any requested output
if get_output:

0 comments on commit 429dac2

Please sign in to comment.
Something went wrong with that request. Please try again.