| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 73a4396 commit 6935a51
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -635,6 +635,9 @@ def execfile(self, filename, source=None): | |||
| 635 | 635 | if source is None: | |
| 636 | 636 | with tokenize.open(filename) as fp: | |
| 637 | 637 | source = fp.read() | |
| 638 | + if use_subprocess: | ||
| 639 | + source = (f"__file__ = r'''{os.path.abspath(filename)}'''\n" | ||
| 640 | + + source + "\ndel __file__") | ||
| 638 | 641 | try: | |
| 639 | 642 | code = compile(source, filename, "exec") | |
| 640 | 643 | except (OverflowError, SyntaxError): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + Set ``__file__`` while running a startup file. Like Python, IDLE optionally | ||
| 2 | + runs one startup file in the Shell window before presenting the first interactive | ||
| 3 | + input prompt. For IDLE, ``-s`` runs a file named in environmental variable | ||
| 4 | + :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`; ``-r file`` runs | ||
| 5 | + ``file``. Python sets ``__file__`` to the startup file name before running the | ||
| 6 | + file and unsets it before the first prompt. IDLE now does the same when run | ||
| 7 | + normally, without the ``-n`` option. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments