You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python py_compile error message inconsistent and missing newline #67999
Running python -m py_compile test.py return the following error message:
Sorry: IndentationError: unexpected indent (test.py, line 6)
But without a newline on stderr at the end of the message. This causes some problems with scripts that expect a newline and new my particular case with reading stderr on docker where docker just ignore the line if it doesn't end in a newline.
Also, this message differs from the runtime error message:
File "test.py", line 6
return []
^
IndentationError: unexpected indent
Would it be possible to at least add in a newline and at best, change the message to be consistent with the runtime error message?
I will trying to look at the code and see if I can write a patch but it will take me some time.
This patch adds new line symbol. For some reason py_compile module prints only SyntaxErrors with traceback. All other exceptions are printed with "Sorry:" and in one line.
Activity
akshetp commentedon Mar 30, 2015
On the following test file (test.py):
Running python -m py_compile test.py return the following error message:
Sorry: IndentationError: unexpected indent (test.py, line 6)
But without a newline on stderr at the end of the message. This causes some problems with scripts that expect a newline and new my particular case with reading stderr on docker where docker just ignore the line if it doesn't end in a newline.
Also, this message differs from the runtime error message:
Would it be possible to at least add in a newline and at best, change the message to be consistent with the runtime error message?
I will trying to look at the code and see if I can write a patch but it will take me some time.
bitdancer commentedon Mar 30, 2015
I can confirm that the bugs is demonstrated by copying the text below into a normal unix text file.
ashkop commentedon Apr 7, 2015
This patch adds new line symbol. For some reason py_compile module prints only SyntaxErrors with traceback. All other exceptions are printed with "Sorry:" and in one line.
python-dev commentedon Apr 14, 2015
New changeset 1e139b3c489e by Berker Peksag in branch '3.4':
Issue bpo-23811: Add missing newline to the PyCompileError error message.
https://hg.python.org/cpython/rev/1e139b3c489e
New changeset d39fe1e112a3 by Berker Peksag in branch 'default':
Issue bpo-23811: Add missing newline to the PyCompileError error message.
https://hg.python.org/cpython/rev/d39fe1e112a3
python-dev commentedon Apr 14, 2015
New changeset 22790c4f3b16 by Berker Peksag in branch '2.7':
Issue bpo-23811: Add missing newline to the PyCompileError error message.
https://hg.python.org/cpython/rev/22790c4f3b16
berkerpeksag commentedon Apr 14, 2015
Thank you Alex.