summaryrefslogtreecommitdiffstats
path: root/Lib/trace.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2023-05-22 10:40:30 (GMT)
committerGitHub <noreply@github.com>2023-05-22 10:40:30 (GMT)
commitd1645ce4f1075d0a6ce051aa10f54f35489aa605 (patch)
tree1abe6a543f295ae97dfad284b783cdfa05016528 /Lib/trace.py
parent98016f7c92aa4c1232c68bac1ed6646db31782ec (diff)
downloadcpython-d1645ce4f1075d0a6ce051aa10f54f35489aa605.zip
cpython-d1645ce4f1075d0a6ce051aa10f54f35489aa605.tar.gz
cpython-d1645ce4f1075d0a6ce051aa10f54f35489aa605.tar.bz2
[3.9] gh-103935: Use `io.open_code()` when executing code in trace and profile modules (GH-103947) (#103953)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Diffstat (limited to 'Lib/trace.py')
-rwxr-xr-xLib/trace.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/trace.py b/Lib/trace.py
index c505d8b..5e1f9cc 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -49,6 +49,7 @@ Sample use, programmatically
"""
__all__ = ['Trace', 'CoverageResults']
+import io
import linecache
import os
import sys
@@ -716,7 +717,7 @@ def main():
sys.argv = [opts.progname, *opts.arguments]
sys.path[0] = os.path.dirname(opts.progname)
- with open(opts.progname, 'rb') as fp:
+ with io.open_code(opts.progname) as fp:
code = compile(fp.read(), opts.progname, 'exec')
# try to emulate __main__ namespace as much as possible
globs = {