diff options
author | Tian Gao <gaogaotiantian@hotmail.com> | 2023-04-27 20:29:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-27 20:29:35 (GMT) |
commit | d50f01ad0a965c6d41e24ef77be0fe643efa1bfd (patch) | |
tree | aa4a9e1f66c134a459d1f4a715860641e12d3b98 /Lib/trace.py | |
parent | bf0b8a9f8d647515170cbdf3b6a8c0f44e0f37b3 (diff) | |
download | cpython-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/trace.py')
-rwxr-xr-x | Lib/trace.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/trace.py b/Lib/trace.py index 213e465..fb9a423 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 = { |