question on the compile built in function. Filename ignored?

Alex Martelli aleax at aleax.it
Wed Apr 30 18:24:50 CEST 2003


Alex wrote:

> I am fairly to new to Python, so please bear with me.
> 
> I am trying to use the built in function compile.  The filename argument
> seems to be ignored no matter what I try.  According to the docs, it
> should
> be used in the output error message.  Here is a simple example:
> 
> Python 2.2.2 (#1, Apr 16 2003, 22:00:16)
> [GCC 3.2.1 20021207 (Gentoo Linux 3.2.1-20021207)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> compile(':\n', 'abc', 'exec')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "<string>", line 1
>     :
>     ^
> SyntaxError: invalid syntax
> 
> 
> From the docs I would expect the line
> 
>   File "<string>", line 1
> 
> to read
> 
>   File "abc", line 1
> 
> 
> What am I missing?

You're missing nothing: this small bug is fixed in Python 2.3 beta 1:

Python 2.3b1 (#1, Apr 26 2003, 10:44:25)
[GCC 3.2 (Mandrake Linux 9.0 3.2-1mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> compile(':\n', 'abc', 'exec')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "abc", line 1
    :
    ^
SyntaxError: invalid syntax
>>>


I don't know if Python is the only software where a "beta" version
seems to have fewer bugs than the previous "stable" version, but my
personal and unofficial impression of Python 2.3 beta 1 is that the
choice to change the language proper very, VERY little (while allowing
some change in the library and built-ins), and focus on stability and
optimization instead, may indeed have had this unexpected result!-)


Alex





More information about the Python-list mailing list