summaryrefslogtreecommitdiffstats
path: root/Lib/cProfile.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/cProfile.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/cProfile.py')
-rwxr-xr-xLib/cProfile.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/cProfile.py b/Lib/cProfile.py
index f7000a8..135a12c 100755
--- a/Lib/cProfile.py
+++ b/Lib/cProfile.py
@@ -8,6 +8,7 @@ __all__ = ["run", "runctx", "Profile"]
import _lsprof
import importlib.machinery
+import io
import profile as _pyprofile
# ____________________________________________________________
@@ -168,7 +169,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)