SyntaxError exception 1.5.1 vs 1.5.2

Tim Peters tim_one at email.msn.com
Wed Sep 1 20:00:25 EDT 1999


[Aahz Maruch, whines on behalf of chris at journyx.com]
> I dunno.  Tim? Fred? Fredrik?  Yoo-hoo!

[chris at journyx.com]
> 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

The code doesn't execute as written; presumably you meant to include an "import
py_compile" line, or you're using your own module of that name.

Anyway, that's where to look.  Python itself hasn't changed here.  The 1.5.2
py_compile.py module clearly catches SyntaxError itself and declines to
re-raise it (read the code).  Don't have 1.5.1 here.  In answer to your
question, neither behavior could be called correct without implying the other
is incorrect, and that would upset someone needlessly <wink>.

i'd-file-a-bug-report-if-i-were-you-ly y'rs  - tim






More information about the Python-list mailing list