mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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:
parent
3523e0c47b
commit
35202c7637
2 changed files with 3 additions and 1 deletions
|
@ -73,6 +73,7 @@ import sys
|
||||||
import os
|
import os
|
||||||
import builtins
|
import builtins
|
||||||
import _sitebuiltins
|
import _sitebuiltins
|
||||||
|
import io
|
||||||
|
|
||||||
# Prefixes for site-packages; add additional prefixes like /usr/local here
|
# Prefixes for site-packages; add additional prefixes like /usr/local here
|
||||||
PREFIXES = [sys.prefix, sys.exec_prefix]
|
PREFIXES = [sys.prefix, sys.exec_prefix]
|
||||||
|
@ -156,7 +157,7 @@ def addpackage(sitedir, name, known_paths):
|
||||||
reset = False
|
reset = False
|
||||||
fullname = os.path.join(sitedir, name)
|
fullname = os.path.join(sitedir, name)
|
||||||
try:
|
try:
|
||||||
f = open(fullname, "r")
|
f = io.TextIOWrapper(io.open_code(fullname))
|
||||||
except OSError:
|
except OSError:
|
||||||
return
|
return
|
||||||
with f:
|
with f:
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
:func:`io.open_code` is now used when reading :file:`.pth` files.
|
Loading…
Add table
Add a link
Reference in a new issue