Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 184f3d4

Browse files
zoobamiss-islington
authored andcommitted
bpo-37364: Use io.open_code() to read .pth files (GH-14299)
https://bugs.python.org/issue37364
1 parent f569092 commit 184f3d4

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

Lib/site.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import os
7474
import builtins
7575
import _sitebuiltins
76+
import io
7677

7778
# Prefixes for site-packages; add additional prefixes like /usr/local here
7879
PREFIXES = [sys.prefix, sys.exec_prefix]
@@ -156,7 +157,7 @@ def addpackage(sitedir, name, known_paths):
156157
reset = False
157158
fullname = os.path.join(sitedir, name)
158159
try:
159-
f = open(fullname, "r")
160+
f = io.TextIOWrapper(io.open_code(fullname))
160161
except OSError:
161162
return
162163
with f:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:func:`io.open_code` is now used when reading :file:`.pth` files.

0 commit comments

Comments
 (0)