Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/py_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ def main():
if args.quiet:
parser.exit(1)
else:
parser.exit(1, error.msg)
parser.exit(1, error.msg + '\n')
except OSError as error:
if args.quiet:
parser.exit(1)
else:
parser.exit(1, str(error))
parser.exit(1, str(error) + '\n')


if __name__ == "__main__":
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_py_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ def test_bad_syntax_with_quiet(self):
self.assertEqual(stdout, b'')
self.assertEqual(stderr, b'')

def test_bad_syntax_stderr_ends_with_newline(self):
with open(self.source_path, 'w') as file:
file.write(' print("hello world")\n')
rc, stdout, stderr = self.pycompilecmd_failure(self.source_path)
self.assertTrue(stderr.endswith(b'\n'))

def test_file_not_exists(self):
should_not_exists = os.path.join(os.path.dirname(__file__), 'should_not_exists.py')
rc, stdout, stderr = self.pycompilecmd_failure(self.source_path, should_not_exists)
Expand Down
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think it’s standard to add Contributed by in the news entry, and I haven’t seen other CPython issues doing that. But I’ve only started contributing here recently, so I could be missing some context.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure py_compile CLI error messages end with a newline. Contributed by Xiao Yuan.
Loading