mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +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
|
@ -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 = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue