[New-bugs-announce] [issue6480] code.runsource() parsing bug

Sean report at bugs.python.org
Tue Jul 14 07:19:58 CEST 2009


New submission from Sean <smcallis at gmail.com>:

I'm writing a little pre-processor that just parses python snippets out
of a file and passes them to a code.InteractiveInterpreter, and I'm
noticing some somewhat nasty stuff in how runsource handles some code.

sys.version:
'2.6.2 (r262:71600, Jul 12 2009, 11:52:33) \n[GCC 4.0.1 (Apple Inc.
build 5465)]'     

Doesn't work:
 interpreter.runsource('print("Foo")\nprint "Bar"')  

Works: 
 interpreter.runsource('print("Foo");print "Bar"')

Doesn't work:
 interpreter.runsource('print("Foo");\nprint "Bar"')  
  

Exact output:
>>> interpreter.runsource('print("Foo")\nprint "Bar"')                 
                                            
Foo                                                                    
                                            
False                                                                  
                                            
>>> interpreter.runsource('print("Foo");print "Bar"')                  
                                            
Foo                                                                    
                                            
Bar                                                                    
                                            
False                                                                  
                                            
>>> interpreter.runsource('print("Foo");\nprint "Bar"')                
                                            
Foo                                                                    
                                            
False                                                                  
                                            
>>>     


Is this a known issue? I didn't see it while searching the bug database...

----------
components: None
messages: 90511
nosy: smcallis
severity: normal
status: open
title: code.runsource() parsing bug
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6480>
_______________________________________


More information about the New-bugs-announce mailing list