Message45687
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 :-(
|
|
Date |
User |
Action |
Args |
2007-08-23 15:36:57 | admin | link | issue924771 messages |
2007-08-23 15:36:57 | admin | create | |
|