[Python-checkins] bpo-45428: Fix reading filenames from stdin in py_compile (GH-28848)

miss-islington webhook-mailer at python.org
Fri Oct 15 08:14:53 EDT 2021


https://github.com/python/cpython/commit/2b6eb8149656541044884e76212495175e061a0a
commit: 2b6eb8149656541044884e76212495175e061a0a
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-10-15T05:14:35-07:00
summary:

bpo-45428: Fix reading filenames from stdin in py_compile (GH-28848)


Strip trailing '\n'.
(cherry picked from commit 59a633d3e2071d65aa6638da5cf767a5c1310271)

Co-authored-by: Graham Inggs <ginggs at debian.org>

files:
A Misc/NEWS.d/next/Library/2021-10-14-18-04-17.bpo-45428.mM2War.rst
M Lib/py_compile.py

diff --git a/Lib/py_compile.py b/Lib/py_compile.py
index 0f9b59025cee3..388614e51b184 100644
--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -190,7 +190,7 @@ def main():
     )
     args = parser.parse_args()
     if args.filenames == ['-']:
-        filenames = sys.stdin.readlines()
+        filenames = [filename.rstrip('\n') for filename in sys.stdin.readlines()]
     else:
         filenames = args.filenames
     for filename in filenames:
diff --git a/Misc/NEWS.d/next/Library/2021-10-14-18-04-17.bpo-45428.mM2War.rst b/Misc/NEWS.d/next/Library/2021-10-14-18-04-17.bpo-45428.mM2War.rst
new file mode 100644
index 0000000000000..556eca43ed3c7
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-10-14-18-04-17.bpo-45428.mM2War.rst
@@ -0,0 +1 @@
+Fix a regression in py_compile when reading filenames from standard input.
\ No newline at end of file



More information about the Python-checkins mailing list