summaryrefslogtreecommitdiffstats
path: root/ptpython/entry_points/run_ptipython.py
diff options
context:
space:
mode:
Diffstat (limited to 'ptpython/entry_points/run_ptipython.py')
-rw-r--r--ptpython/entry_points/run_ptipython.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/ptpython/entry_points/run_ptipython.py b/ptpython/entry_points/run_ptipython.py
index 650633e..b660a0a 100644
--- a/ptpython/entry_points/run_ptipython.py
+++ b/ptpython/entry_points/run_ptipython.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+from __future__ import annotations
+
import os
import sys
@@ -31,7 +33,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()
@@ -58,7 +60,7 @@ def run(user_ns=None):
code = compile(f.read(), path, "exec")
exec(code, user_ns, user_ns)
else:
- print("File not found: {}\n\n".format(path))
+ print(f"File not found: {path}\n\n")
sys.exit(1)
# Apply config file