This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jaredgrubb
Recipients gvanrossum, jaredgrubb
Date 2008-04-08.06:07:12
SpamBayes Score 0.050261546
Marked as misclassified No
Message-id <1207634833.9.0.803279960178.issue2182@psf.upfronthosting.co.za>
In-reply-to
Content
Yes, but exec(string) also gives a syntax error for \r\n:

exec('x=1\r\nprint x') 

The only explanation I could find for ONLY permitting \n as newlines in
 exec(string) comes from PEP278: "There is no support for universal
newlines in strings passed to eval() or exec. It is envisioned that such
strings always have the standard \n line feed, if the strings come from
a file that file can be read with universal newlines." (This is why my
original example had to be exec(file) and not just a simple exec(string))

Of the 3 newline types, exec(*) allows 1 or all 3 as the case may be,
and tokenize allows exactly 2 of them. I honestly am not sure what the
"right" way is (or should be), but either way, the tokenize module is
not consistent with exec.

(By the way, if you're curious why I filed this issue and Issue#2180,
I'm working on the PyPy project to help improve its current Python
lexer/parser. In order to ensure that it is correct and robust, I was
experimenting with corner cases in Python syntax and I found these cases
where tokenize disagrees with exec.)
History
Date User Action Args
2008-04-08 06:07:14jaredgrubbsetspambayes_score: 0.0502615 -> 0.050261546
recipients: + jaredgrubb, gvanrossum
2008-04-08 06:07:13jaredgrubbsetspambayes_score: 0.0502615 -> 0.0502615
messageid: <1207634833.9.0.803279960178.issue2182@psf.upfronthosting.co.za>
2008-04-08 06:07:13jaredgrubblinkissue2182 messages
2008-04-08 06:07:12jaredgrubbcreate