mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
gh-103935: Use io.open_code()
when executing code in trace and profile modules (GH-103947)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
This commit is contained in:
parent
dbc44fab7a
commit
57d198ec83
4 changed files with 7 additions and 3 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue