mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-103935: Use io.open_code()
when executing code in trace and profile modules (GH-103947)
This commit is contained in:
parent
bf0b8a9f8d
commit
d50f01ad0a
4 changed files with 7 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue