[Python-Dev] Compile() and Windows/Mac newlines

Terry Reedy tjreedy at udel.edu
Wed Dec 29 20:31:20 CET 2010


In python-list thread "Does Python 3.1 accept \r\n in compile()?"
jmfauth notes that
compile('print(999)\r\n', '<in>', 'exec')
works in 2.7 but not 3.1 (and 3.2 not checked) because 3.1 sees '\r' as
SyntaxError.

I started to respond that this is part of Py3 cleanup with newlines 
converted on input and back-compatibility with ancient Python not 
needed. Then I saw in 3.2 manual

"Changed in version 3.2: Allowed use of Windows and Mac newlines. Also 
input in 'exec' mode does not have to end in a newline anymore. Added 
the optimize parameter."

I verified second statement ("print(999)" works) (and remember commit 
for third), but original above gives same error. Should "Allowed use of 
Windows and Mac newlines." be deleted? What else could it mean other 
than use of '\r' or '\r\n'?

-- 
Terry Jan Reedy



More information about the Python-Dev mailing list