Bug 1184112 still valid
Hello, today I got my first real python bug. Problem is described in: Bug with ID: 1184112 http://sourceforge.net/tracker/index.php?func=detail&aid=1184112&group_id=5470&atid=105470 I use python 2.3.5 in an embedded C++ Application which uses function: PyRun_SimpleString. Is this bug still present in current python or the 2.4 line ? I found nothing about it. -- bye by Wolfgang
Wolfgang Langner wrote:
Hello,
today I got my first real python bug. Problem is described in:
Bug with ID: 1184112
http://sourceforge.net/tracker/index.php?func=detail&aid=1184112&group_id=5470&atid=105470
I use python 2.3.5 in an embedded C++ Application which uses function: PyRun_SimpleString.
Is this bug still present in current python or the 2.4 line ? I found nothing about it.
Confirmed on SVN trunk. I don't know enough about the tokenizer to determine if the proposed fix is the best solution, though. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org
Wolfgang Langner wrote:
today I got my first real python bug. Problem is described in:
Bug with ID: 1184112
http://sourceforge.net/tracker/index.php?func=detail&aid=1184112&group_id=5470&atid=105470
I use python 2.3.5 in an embedded C++ Application which uses function: PyRun_SimpleString.
the "missing trailing newline may cause errors for multiline statements" is documented behaviour; from the compile() docs: "When compiling multi-line statements, two caveats apply: line endings must be represented by a single newline character ('\n'), and the input must be terminated by at least one newline character." see the codeop.py sources for library code that depends on this behaviour. </F>
"Fredrik Lundh"
http://sourceforge.net/tracker/index.php?func=detail&aid=1184112&group_id=5470&atid=105470 "When compiling multi-line statements, two caveats apply: line endings must be represented by a single newline character ('\n'), and the input must be terminated by at least one newline character."
Relevant part of quote added to bug report. tjr
Terry Reedy wrote:
"Fredrik Lundh"
wrote in message news:dveini$ntv$1@sea.gmane.org... http://sourceforge.net/tracker/index.php?func=detail&aid=1184112&group_id=5470&atid=105470 "When compiling multi-line statements, two caveats apply: line endings must be represented by a single newline character ('\n'), and the input must be terminated by at least one newline character."
Relevant part of quote added to bug report.
One quirk though, is that omitting the newline actually works for some other statements (e.g. exec "if 1:\n print 'Hello world!'" works just fine) However, I don't think the quote is as relevant as one might think, because in the code that fails the multi-line statement is not only terminated by a newline, it's actually followed by a blank line as well. The line missing the newline is only a single-line statement (specifically, a line with only a comment). Compare: Py> exec """ ... if 1: ... print 'This works!' ... ... pass # Do nothing at all""" This works! With: Py> exec """ ... if 1: ... print 'This breaks!' ... ... # Do nothing at all""" Traceback (most recent call last): File "<stdin>", line 1, in ? File "<string>", line 5 # Do nothing at all ^ SyntaxError: invalid syntax There's an easy workaround (adding the missing newline), but I think there's definitely something going wrong in the tokenizer. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org
participants (4)
-
Fredrik Lundh
-
Nick Coghlan
-
Terry Reedy
-
Wolfgang Langner