This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: py_compile.compile SyntaxError output
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7, Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, nheron, python-dev, r.david.murray
Priority: normal Keywords: patch

Created on 2010-02-02 22:50 by nheron, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
py_compile_patch.diff nheron, 2010-02-02 22:50 patch review
Messages (4)
msg98766 - (view) Author: Nigel Heron (nheron) Date: 2010-02-02 22:50
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('','w')
f.write("1 = a  #<-- obvious syntax err\n")
import py_compile
msg102674 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2010-04-09 03:15
Change went into py3k without tests, do we want them? If so, please update Stage to "test needed".
msg182458 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-02-20 01:01
New changeset c7f04c09dc56 by R David Murray in branch '2.7':
#7842: backport fix for py_compile.compile syntax error message handling.
msg182460 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-02-20 01:03
Better late than never.  Be nice if someone would contribute a test, but I'm not going let that hold things up for such a simple patch that is already in default with no test.
Date User Action Args
2022-04-11 14:56:57adminsetgithub: 52090
2013-02-20 01:03:32r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg182460

resolution: fixed
stage: patch review -> resolved
2013-02-20 01:01:15python-devsetnosy: + python-dev
messages: + msg182458
2010-04-09 03:15:53ajaksu2setpriority: normal

nosy: + ajaksu2
messages: + msg102674

stage: patch review
2010-02-02 22:50:03nheroncreate