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:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-07-17 07:40:58 +0000
commit302975348b0dbd4f0ddbb699df76ee05ffbefaaf (patch)
tree761e94c321db07dec57816b4ffdd36a13d67662d /ptpython/entry_points/run_ptpython.py
parentReleasing debian version 3.0.16-2. (diff)
downloadptpython-302975348b0dbd4f0ddbb699df76ee05ffbefaaf.tar.xz
ptpython-302975348b0dbd4f0ddbb699df76ee05ffbefaaf.zip
Merging upstream version 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: