From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 21 Jun 2019 22:35:44 +0000 (-0700) Subject: bpo-37364: Use io.open_code() to read .pth files (GH-14299) X-Git-Tag: v3.8.0b2~79 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=35202c763703c9c00345b4445a638211e6e37bbc;p=python bpo-37364: Use io.open_code() to read .pth files (GH-14299) https://bugs.python.org/issue37364 (cherry picked from commit 184f3d4f39056f6fe450d007d3b9b61d811a2a4d) Co-authored-by: Steve Dower --- diff --git a/Lib/site.py b/Lib/site.py index ad1146332b..e7aafb7011 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -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 index 0000000000..7506fa9064 --- /dev/null +++ b/Misc/NEWS.d/next/Security/2019-06-21-14-42-53.bpo-37364.IIRc2s.rst @@ -0,0 +1 @@ +:func:`io.open_code` is now used when reading :file:`.pth` files.