Title: work around to compile \r\n file
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, quiver
Priority: normal Keywords: patch

Created on 2004-03-28 06:40 by quiver, last changed 2007-08-23 20:15 by georg.brandl. This issue is now closed.

File name Uploaded Description Edit
compile.patch quiver, 2004-03-28 06:40
Messages (2)
msg45687 - (view) Author: George Yoshida (quiver) (Python committer) Date: 2004-03-28 06:40
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 

For example:

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

SyntaxError: invalid syntax

Lib/ 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 :-(
msg55198 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-08-23 20:15
The offending open() call in is fixed, so closing this.
Date User Action Args
2007-08-23 20:15:47georg.brandlsetstatus: open -> closed
resolution: out of date
messages: + msg55198
nosy: + georg.brandl
2004-03-28 06:40:13quivercreate