Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue6480] code.runsource() parsing bug

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Jul 13, 2009, 10:19 PM

Post #1 of 2 (179 views)
Permalink
[issue6480] code.runsource() parsing bug

New submission from Sean <smcallis [at] gmail>:

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>
<http://bugs.python.org/issue6480>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 14, 2009, 2:16 PM

Post #2 of 2 (156 views)
Permalink
[issue6480] code.runsource() parsing bug [In reply to]

Sean <smcallis [at] gmail> added the comment:

Seems to me it's probably an issue with the newlines, but from
help(code.compile_command):

Compile a command and determine whether it is incomplete.

Arguments:

source -- the source string; <b>may contain \n characters</b>
filename -- optional filename from which source was read; default
"<input>"
symbol -- optional grammar start symbol; "single" (default) or

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue6480>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.