[issue7842] py_compile.compile SyntaxError output

Nigel Heron report at bugs.python.org
Tue Feb 2 23:50:04 CET 2010


New submission from Nigel Heron <nigel at psycode.com>:

when a syntax error is generated in py_compile.compile(), the wrong arguments are passed to the new PyCompileError exception which in turn passes the wrong args to traceback.format_exception_only() producing the wrong output.

this was fixed in the py3k branch (Revision 56901) but is still broken in 2.6 and 2.7
the attached patch has the same fix but applied to the trunk.

here's a simple test case..

f = open('broken.py','w')
f.write("1 = a  #<-- obvious syntax err\n")
f.close()
import py_compile
py_compile.compile('broken.py')

----------
components: Library (Lib)
files: py_compile_patch.diff
keywords: patch
messages: 98766
nosy: nheron
severity: normal
status: open
title: py_compile.compile SyntaxError output
type: behavior
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file16114/py_compile_patch.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7842>
_______________________________________


More information about the Python-bugs-list mailing list