diff options
author | Steve Dower <steve.dower@python.org> | 2023-05-22 10:40:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-22 10:40:30 (GMT) |
commit | d1645ce4f1075d0a6ce051aa10f54f35489aa605 (patch) | |
tree | 1abe6a543f295ae97dfad284b783cdfa05016528 /Lib/cProfile.py | |
parent | 98016f7c92aa4c1232c68bac1ed6646db31782ec (diff) | |
download | cpython-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/cProfile.py')
-rwxr-xr-x | Lib/cProfile.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/cProfile.py b/Lib/cProfile.py index 22a7d0a..9ae1fb8 100755 --- a/Lib/cProfile.py +++ b/Lib/cProfile.py @@ -7,6 +7,7 @@ __all__ = ["run", "runctx", "Profile"] import _lsprof +import io import profile as _pyprofile # ____________________________________________________________ @@ -167,7 +168,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') globs = { '__file__': progname, |