summaryrefslogtreecommitdiffstats
path: root/ptpython/entry_points/run_ptpython.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-07-17 07:40:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-07-17 07:40:54 +0000
commit8188ef390db734738d245336d1d619516ca746d4 (patch)
tree36dc902621c535d2567244ce020d614858c9ddee /ptpython/entry_points/run_ptpython.py
parentAdding upstream version 3.0.16. (diff)
downloadptpython-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/run_ptpython.py')
-rw-r--r--ptpython/entry_points/run_ptpython.py8
1 files changed, 5 insertions, 3 deletions
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: