[pypy-svn] r15468 - pypy/dist/pypy/translator/goal
hpk at codespeak.net
hpk at codespeak.net
Sun Jul 31 14:57:33 CEST 2005
Author: hpk
Date: Sun Jul 31 14:57:32 2005
New Revision: 15468
Modified:
pypy/dist/pypy/translator/goal/app_main.py
pypy/dist/pypy/translator/goal/targetpypymain.py
Log:
(arigo, hpk)
refactored the main entry_point so that it accepts
no arguments (starting code.interact()) or just a
single string argument (compiling and running the
given filename).
Modified: pypy/dist/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/dist/pypy/translator/goal/app_main.py (original)
+++ pypy/dist/pypy/translator/goal/app_main.py Sun Jul 31 14:57:32 2005
@@ -4,19 +4,29 @@
def entry_point(argv):
import sys
- sys.executable = argv[0]
- sys.argv = argv[1:]
+ sys.executable = "pypy"
+ sys.argv = argv
# with PyPy in top of CPython we can only have around 100
# but we need more in the translated PyPy for the compiler package
- sys.setrecursionlimit(1000)
+ sys.setrecursionlimit(5000)
mainmodule = type(sys)('__main__')
sys.modules['__main__'] = mainmodule
try:
- execfile(sys.argv[0], mainmodule.__dict__)
+ if argv:
+ execfile(sys.argv[0], mainmodule.__dict__)
+ else:
+ print >> sys.stderr, "importing code"
+ import code
+ print >> sys.stderr, "calling code.interact()"
+ code.interact(local=mainmodule.__dict__)
except:
- sys.excepthook(*sys.exc_info())
+ excinfo = sys.exc_info()
+ typ, val, tb = excinfo
+ print >> sys.stderr, "exception-type:", typ.__name__
+ print >> sys.stderr, "exception-value:", str(val)
+ sys.excepthook(typ, val, tb)
return 1
else:
return 0
@@ -24,4 +34,4 @@
if __name__ == '__main__':
# debugging only
import sys
- sys.exit(entry_point(sys.argv))
+ sys.exit(entry_point(sys.argv[1:]))
Modified: pypy/dist/pypy/translator/goal/targetpypymain.py
==============================================================================
--- pypy/dist/pypy/translator/goal/targetpypymain.py (original)
+++ pypy/dist/pypy/translator/goal/targetpypymain.py Sun Jul 31 14:57:32 2005
@@ -63,7 +63,7 @@
w_entry_point = space.getitem(w_dict, space.wrap('entry_point'))
# sanity-check: call the entry point
- res = entry_point("pypy\x00app_example.py")
+ res = entry_point("app_example.py")
assert res == 0
return entry_point, [SomeString()]
@@ -76,6 +76,6 @@
# _____ Run translated _____
def run(c_entry_point):
- argv = ["pypy", os.path.join(this_dir, 'app_example.py')]
+ argv = [os.path.join(this_dir, 'app_example.py')]
exitcode = c_entry_point('\x00'.join(argv))
assert exitcode == 0
More information about the Pypy-commit
mailing list