bpo-37364: Use io.open_code() to read .pth files (GH-14299)

https://bugs.python.org/issue37364
(cherry picked from commit 184f3d4f39)

Co-authored-by: Steve Dower <steve.dower@python.org>
This commit is contained in:
Miss Islington (bot) 2019-06-21 15:35:44 -07:00 committed by GitHub
parent 3523e0c47b
commit 35202c7637
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View 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:

View file

@ -0,0 +1 @@
:func:`io.open_code` is now used when reading :file:`.pth` files.