summaryrefslogtreecommitdiffstats
path: root/Lib/profile.py
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2023-04-27 20:29:35 (GMT)
committerGitHub <noreply@github.com>2023-04-27 20:29:35 (GMT)
commitd50f01ad0a965c6d41e24ef77be0fe643efa1bfd (patch)
treeaa4a9e1f66c134a459d1f4a715860641e12d3b98 /Lib/profile.py
parentbf0b8a9f8d647515170cbdf3b6a8c0f44e0f37b3 (diff)
downloadcpython-d50f01ad0a965c6d41e24ef77be0fe643efa1bfd.zip
cpython-d50f01ad0a965c6d41e24ef77be0fe643efa1bfd.tar.gz
cpython-d50f01ad0a965c6d41e24ef77be0fe643efa1bfd.tar.bz2
gh-103935: Use `io.open_code()` when executing code in trace and profile modules (GH-103947)
Diffstat (limited to 'Lib/profile.py')
-rwxr-xr-xLib/profile.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/profile.py b/Lib/profile.py
index 453e562..4b82523 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -25,6 +25,7 @@
import importlib.machinery
+import io
import sys
import time
import marshal
@@ -588,7 +589,7 @@ def main():
else:
progname = args[0]
sys.path.insert(0, os.path.dirname(progname))
- with open(progname, 'rb') as fp:
+ with io.open_code(progname) as fp:
code = compile(fp.read(), progname, 'exec')
spec = importlib.machinery.ModuleSpec(name='__main__', loader=None,
origin=progname)