[pypy-svn] r7502 - pypy/trunk/src/pypy/module

arigo at codespeak.net arigo at codespeak.net
Sat Nov 20 12:52:56 CET 2004


Author: arigo
Date: Sat Nov 20 12:52:56 2004
New Revision: 7502

Modified:
   pypy/trunk/src/pypy/module/sysinterp.py
   pypy/trunk/src/pypy/module/sysmodule.py
Log:
Moved sys.displayhook to app-level.



Modified: pypy/trunk/src/pypy/module/sysinterp.py
==============================================================================
--- pypy/trunk/src/pypy/module/sysinterp.py	(original)
+++ pypy/trunk/src/pypy/module/sysinterp.py	Sat Nov 20 12:52:56 2004
@@ -95,15 +95,17 @@
             "trying to change the builtin-in module %r" % (name,))
     space.setitem(w_modules, space.wrap(name), w_module)
 
-def displayhook(w_x):
-    w = space.wrap
-    if not space.is_true(space.is_(w_x, space.w_None)):
-        try:
-            # XXX don't use print, send to sys.stdout instead
-            print space.unwrap(space.repr(w_x))
-        except OperationError:
-            print "! could not print", w_x
-        space.setitem(space.w_builtins, w('_'), w_x)
+##def displayhook(w_x):
+##    w = space.wrap
+##    if not space.is_true(space.is_(w_x, space.w_None)):
+##        w_stdout = space.getattr(space.w_sys, space.wrap('stdout'))
+##        try:
+##            w_repr = space.repr(w_x)
+##        except OperationError:
+##            w_repr = space.wrap("! __repr__ raised an exception")
+##        w_repr = space.add(w_repr, space.wrap("\n"))
+##        space.call_method(w_stdout, 'write', 
+##        space.setitem(space.w_builtins, w('_'), w_x)
 
 def _getframe():
     # XXX No Argument Accepted Yet

Modified: pypy/trunk/src/pypy/module/sysmodule.py
==============================================================================
--- pypy/trunk/src/pypy/module/sysmodule.py	(original)
+++ pypy/trunk/src/pypy/module/sysmodule.py	Sat Nov 20 12:52:56 2004
@@ -15,7 +15,7 @@
 from __interplevel__ import pypy_objspaceclass
 
 # Functions from interpreter-level
-from __interplevel__ import displayhook, _getframe, exc_info
+from __interplevel__ import _getframe, exc_info
 
 # Dummy
 executable = ''
@@ -31,3 +31,8 @@
 
 def exit(exitcode=0):
     raise SystemExit(exitcode)
+
+def displayhook(obj):
+    if obj is not None:
+        __builtins__['_'] = obj
+        stdout.write(`obj` + '\n')



More information about the Pypy-commit mailing list