| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | 9 | import _lsprof | |
| 10 | 10 | import importlib.machinery | |
| 11 | + import io | ||
| 11 | 12 | import profile as _pyprofile | |
| 12 | 13 | ||
| 13 | 14 | # ____________________________________________________________ | |
@@ -168,7 +169,7 @@ def main(): | |||
| 168 | 169 | else: | |
| 169 | 170 | progname = args[0] | |
| 170 | 171 | sys.path.insert(0, os.path.dirname(progname)) | |
| 171 | - with open(progname, 'rb') as fp: | ||
| 172 | + with io.open_code(progname) as fp: | ||
| 172 | 173 | code = compile(fp.read(), progname, 'exec') | |
| 173 | 174 | spec = importlib.machinery.ModuleSpec(name='__main__', loader=None, | |
| 174 | 175 | origin=progname) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | import importlib.machinery | |
| 28 | + import io | ||
| 28 | 29 | import sys | |
| 29 | 30 | import time | |
| 30 | 31 | import marshal | |
@@ -588,7 +589,7 @@ def main(): | |||
| 588 | 589 | else: | |
| 589 | 590 | progname = args[0] | |
| 590 | 591 | sys.path.insert(0, os.path.dirname(progname)) | |
| 591 | - with open(progname, 'rb') as fp: | ||
| 592 | + with io.open_code(progname) as fp: | ||
| 592 | 593 | code = compile(fp.read(), progname, 'exec') | |
| 593 | 594 | spec = importlib.machinery.ModuleSpec(name='__main__', loader=None, | |
| 594 | 595 | origin=progname) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,6 +49,7 @@ | |||
| 49 | 49 | """ | |
| 50 | 50 | __all__ = ['Trace', 'CoverageResults'] | |
| 51 | 51 | ||
| 52 | + import io | ||
| 52 | 53 | import linecache | |
| 53 | 54 | import os | |
| 54 | 55 | import sys | |
@@ -716,7 +717,7 @@ def parse_ignore_dir(s): | |||
| 716 | 717 | sys.argv = [opts.progname, *opts.arguments] | |
| 717 | 718 | sys.path[0] = os.path.dirname(opts.progname) | |
| 718 | 719 | ||
| 719 | - with open(opts.progname, 'rb') as fp: | ||
| 720 | + with io.open_code(opts.progname) as fp: | ||
| 720 | 721 | code = compile(fp.read(), opts.progname, 'exec') | |
| 721 | 722 | # try to emulate __main__ namespace as much as possible | |
| 722 | 723 | globs = { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Use :func:`io.open_code` for files to be executed instead of raw :func:`open` | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments