[Patches] [ python-Patches-924771 ] work around to compile \r\n file
SourceForge.net
noreply at sourceforge.net
Sun Mar 28 01:40:13 EST 2004
Patches item #924771, was opened at 2004-03-28 15:40
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=924771&group_id=5470
Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: George Yoshida (quiver)
Assigned to: Nobody/Anonymous (nobody)
Summary: work around to compile \r\n file
Initial Comment:
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 :-(
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=924771&group_id=5470
More information about the Patches
mailing list