[Python-checkins] bpo-40260: Remove unnecessary newline in compile() call (GH-19641)

Miss Islington (bot) webhook-mailer at python.org
Wed Apr 22 15:05:18 EDT 2020


https://github.com/python/cpython/commit/fc45cb4400409572f05c8b54f2c6f06cbefb1b4e
commit: fc45cb4400409572f05c8b54f2c6f06cbefb1b4e
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-04-22T12:05:10-07:00
summary:

bpo-40260: Remove unnecessary newline in compile() call (GH-19641)


Because some people subclass this class and call undocumented methods, and we don't want to break them.
(cherry picked from commit 39652cd8bdf7c82b7c6055089a4ed90ee546a448)

Co-authored-by: Anthony Sottile <asottile at umich.edu>

files:
M Lib/modulefinder.py

diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py
index 361a6730c0674..aadcd23edbaaa 100644
--- a/Lib/modulefinder.py
+++ b/Lib/modulefinder.py
@@ -339,7 +339,7 @@ def load_module(self, fqname, fp, pathname, file_info):
             self.msgout(2, "load_module ->", m)
             return m
         if type == _PY_SOURCE:
-            co = compile(fp.read()+b'\n', pathname, 'exec')
+            co = compile(fp.read(), pathname, 'exec')
         elif type == _PY_COMPILED:
             try:
                 data = fp.read()



More information about the Python-checkins mailing list