summaryrefslogtreecommitdiffstats
path: root/Lib/runpy.py
diff options
context:
space:
mode:
authorjsnklln <jsnklln@gmail.com>2019-11-18 19:11:13 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-11-18 19:11:13 (GMT)
commite243bae9999418859106328d9fce71815b7eb2fe (patch)
tree4d9c4e6611fe6f0133ed2968237914f435bc7787 /Lib/runpy.py
parentbcc1cc5cc38b57ac55cbe710849374258d610a08 (diff)
downloadcpython-e243bae9999418859106328d9fce71815b7eb2fe.zip
cpython-e243bae9999418859106328d9fce71815b7eb2fe.tar.gz
cpython-e243bae9999418859106328d9fce71815b7eb2fe.tar.bz2
bpo-38722: Runpy use io.open_code() (GH-17234)
https://bugs.python.org/issue38722 Automerge-Triggered-By: @taleinat
Diffstat (limited to 'Lib/runpy.py')
-rw-r--r--Lib/runpy.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/runpy.py b/Lib/runpy.py
index d86f0e4..8adc91e 100644
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -13,6 +13,7 @@ importers when locating support scripts as well as when importing modules.
import sys
import importlib.machinery # importlib first so we can test #15386 via -m
import importlib.util
+import io
import types
from pkgutil import read_code, get_importer
@@ -228,11 +229,11 @@ def _get_main_module_details(error=ImportError):
def _get_code_from_file(run_name, fname):
# Check for a compiled file first
- with open(fname, "rb") as f:
+ with io.open_code(fname) as f:
code = read_code(f)
if code is None:
# That didn't work, so try it as normal source code
- with open(fname, "rb") as f:
+ with io.open_code(fname) as f:
code = compile(f.read(), fname, 'exec')
return code, fname