[pypy-svn] r4981 - pypy/branch/src-newobjectmodel/pypy/interpreter

arigo at codespeak.net arigo at codespeak.net
Sat Jun 5 17:46:05 CEST 2004


Author: arigo
Date: Sat Jun  5 17:46:04 2004
New Revision: 4981

Modified:
   pypy/branch/src-newobjectmodel/pypy/interpreter/interactive.py
Log:
Interactive console improvements.
Ctrl-C gives you a CPython prompt to play with PyPy at interpreter-level.


Modified: pypy/branch/src-newobjectmodel/pypy/interpreter/interactive.py
==============================================================================
--- pypy/branch/src-newobjectmodel/pypy/interpreter/interactive.py	(original)
+++ pypy/branch/src-newobjectmodel/pypy/interpreter/interactive.py	Sat Jun  5 17:46:04 2004
@@ -18,15 +18,26 @@
 
     def interact(self, banner=None):
         if banner is None:
-            banner = "Python %s in pypy\n%s / %s" % (
-                sys.version, self.__class__.__name__,
-                self.space.__class__.__name__)
+            #banner = "Python %s in pypy\n%s / %s" % (
+            #    sys.version, self.__class__.__name__,
+            #    self.space.__class__.__name__)
+            banner = "PyPy in %s on top of Python %s" % (
+                self.space.__class__.__name__, sys.version.split()[0])
         code.InteractiveConsole.interact(self, banner)
 
     def raw_input(self, prompt=""):
         # add a character to the PyPy prompt so that you know where you
         # are when you debug it with "python -i py.py"
-        return code.InteractiveConsole.raw_input(self, prompt[0] + prompt)
+        try:
+            return code.InteractiveConsole.raw_input(self, prompt[0] + prompt)
+        except KeyboardInterrupt:
+            # fires into an interpreter-level console
+            print
+            banner = ("Python %s on %s\n" % (sys.version, sys.platform) +
+                      "*** Entering interpreter-level console ***")
+            code.interact(banner=banner, local=self.__dict__)
+            print '*** Leaving interpreter-level console ***'
+            raise
 
     def runcode(self, code):
         # 'code' is a CPython code object



More information about the Pypy-commit mailing list