diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-07-17 07:40:54 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-07-17 07:40:54 +0000 |
commit | 8188ef390db734738d245336d1d619516ca746d4 (patch) | |
tree | 36dc902621c535d2567244ce020d614858c9ddee /ptpython/entry_points | |
parent | Adding upstream version 3.0.16. (diff) | |
download | ptpython-8188ef390db734738d245336d1d619516ca746d4.tar.xz ptpython-8188ef390db734738d245336d1d619516ca746d4.zip |
Adding upstream version 3.0.19.upstream/3.0.19
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ptpython/entry_points')
-rw-r--r-- | ptpython/entry_points/run_ptipython.py | 2 | ||||
-rw-r--r-- | ptpython/entry_points/run_ptpython.py | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/ptpython/entry_points/run_ptipython.py b/ptpython/entry_points/run_ptipython.py index 650633e..21d7063 100644 --- a/ptpython/entry_points/run_ptipython.py +++ b/ptpython/entry_points/run_ptipython.py @@ -31,7 +31,7 @@ def run(user_ns=None): path = a.args[0] with open(path, "rb") as f: code = compile(f.read(), path, "exec") - exec(code, {}) + exec(code, {"__name__": "__main__", "__file__": path}) else: enable_deprecation_warnings() diff --git a/ptpython/entry_points/run_ptpython.py b/ptpython/entry_points/run_ptpython.py index 0b3dbdb..5ebe2b9 100644 --- a/ptpython/entry_points/run_ptpython.py +++ b/ptpython/entry_points/run_ptpython.py @@ -179,9 +179,11 @@ def run() -> None: path = a.args[0] with open(path, "rb") as f: code = compile(f.read(), path, "exec") - # NOTE: We have to pass an empty dictionary as namespace. Omitting - # this argument causes imports to not be found. See issue #326. - exec(code, {}) + # NOTE: We have to pass a dict as namespace. Omitting this argument + # causes imports to not be found. See issue #326. + # However, an empty dict sets __name__ to 'builtins', which + # breaks `if __name__ == '__main__'` checks. See issue #444. + exec(code, {"__name__": "__main__", "__file__": path}) # Run interactive shell. else: |