SyntaxError exception 1.5.1 vs 1.5.2
Michael P. Reilly
arcege at shore.net
Wed Sep 1 15:47:15 EDT 1999
Aahz Maruch <aahz at netcom.com> wrote:
: In article <7q7822$ba6$1 at nnrp1.deja.com>, <chris at journyx.com> wrote:
:>
:>i've noticed differences between 1.5.1 and 1.5.2 wrt: handling a
:>SyntaxError exception. Which behavior is correct?
:>
:>Here is the scenario:
:>
:>bad_syntax.py:
:>hello"
:>
:>build_py.py:
:>import sys
:>
:>try:
:> py_compile.compile('bad_syntax.py')
:> print "after compile"
:>except:
:> print "compile error"
:>
:>now the output:
:>
:>python1.5.1:
:>compile error
:>
:>python1.5.2:
:>File "bad_syntax.py", line 1
:> hello"
:> ^
:>SyntaxError: invalid token
:>after compile
: I dunno. Tim? Fred? Fredrik? Yoo-hoo!
Very interesting indeed. It seems that the Python 1.5.2
py_compile.compile function prints a traceback and returns instead of
re-raising the exception or returning an error (ie. different value
from what a normal execution gives).
I think this may be to aid compileall.py (but in a bad manner to my way
of thinking).
-Arcege
More information about the Python-list
mailing list