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 quiver
Recipients
Date 2004-03-28.06:40:13
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
On Unix-like systems, built-in function compile cannot 
compile files that don't use linefeed as an EOL. But there 
are several codes in the library which assume that input 
files use valid EOL characters.
So when they come across \r\n(or \r) on Unix 
environments, compile causes the parser to raise a 
SyntaxError.

For example:

>>> list(file('a.py'))
['\r\n']
>>> import trace
>>> trace.find_executable_linenos('a.py')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/trace.py", line 389, in 
find_executable_linenos
    code = compile(prog, filename, "exec")
  File "a.py", line 1

    ^
SyntaxError: invalid syntax

Lib/py_compile.py opens files with 'U' option to handle 
file format differences and I think this is the way to go.

There is one drawback.
When Python is configured without universal newline 
support, this approach doesn't work :-(
History
Date User Action Args
2007-08-23 15:36:57adminlinkissue924771 messages
2007-08-23 15:36:57admincreate