bug in builtin compile function?
Michael McCandless
mail at mikemccandless.com
Sun Oct 14 15:30:21 EDT 2001
Hi,
If I have a file, foo.py, that has a syntax error in it, and I create a
separate bar.py that tries to load and compile the contents of foo.py
like this:
s = open('foo.py').read()
compile(s, 'foo.py', 'exec')
Then I get a traceback like this:
Traceback (innermost last):
File "bar.py", line 3, in ?
compile(s, 'foo.py', 'exec')
File "<string>", line 2
ajdsf:
^
SyntaxError: invalid syntax
My question is: why does the SyntaxError say:
File "<string>", line 2
instead of:
File "foo.py", line 2
?
I told compile that the file was "foo.py", so, why doesn't it say that
in the SyntaxError instead of saying <string>?
Thanks.
Mike
More information about the Python-list
mailing list