]> granicus.if.org Git - python/commitdiff
bpo-37364: Use io.open_code() to read .pth files (GH-14299)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 21 Jun 2019 22:35:44 +0000 (15:35 -0700)
committerGitHub <noreply@github.com>
Fri, 21 Jun 2019 22:35:44 +0000 (15:35 -0700)
https://bugs.python.org/issue37364
(cherry picked from commit 184f3d4f39056f6fe450d007d3b9b61d811a2a4d)

Co-authored-by: Steve Dower <steve.dower@python.org>
Lib/site.py
Misc/NEWS.d/next/Security/2019-06-21-14-42-53.bpo-37364.IIRc2s.rst [new file with mode: 0644]

index ad1146332b0ab7b65df640069bbeb4b6494bbad9..e7aafb7011cfc7ea3634b9d4b531f801c53f6dbe 100644 (file)
@@ -73,6 +73,7 @@ import sys
 import os
 import builtins
 import _sitebuiltins
+import io
 
 # Prefixes for site-packages; add additional prefixes like /usr/local here
 PREFIXES = [sys.prefix, sys.exec_prefix]
@@ -156,7 +157,7 @@ def addpackage(sitedir, name, known_paths):
         reset = False
     fullname = os.path.join(sitedir, name)
     try:
-        f = open(fullname, "r")
+        f = io.TextIOWrapper(io.open_code(fullname))
     except OSError:
         return
     with f:
diff --git a/Misc/NEWS.d/next/Security/2019-06-21-14-42-53.bpo-37364.IIRc2s.rst b/Misc/NEWS.d/next/Security/2019-06-21-14-42-53.bpo-37364.IIRc2s.rst
new file mode 100644 (file)
index 0000000..7506fa9
--- /dev/null
@@ -0,0 +1 @@
+:func:`io.open_code` is now used when reading :file:`.pth` files.