bpo-37364: Use io.open_code() to read .pth files (GH-14299)
https://bugs.python.org/issue37364
diff --git a/Lib/site.py b/Lib/site.py
index ad11463..e7aafb7 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -73,6 +73,7 @@
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 @@
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: