[pypy-svn] rev 726 - pypy/trunk/src/pypy/module

mwh at codespeak.net mwh at codespeak.net
Fri May 30 13:16:30 CEST 2003


Author: mwh
Date: Fri May 30 13:16:30 2003
New Revision: 726

Modified:
   pypy/trunk/src/pypy/module/sysmodule.py
Log:
make a stab at a better sys.path
add less irritating sys.displayhook


Modified: pypy/trunk/src/pypy/module/sysmodule.py
==============================================================================
--- pypy/trunk/src/pypy/module/sysmodule.py	(original)
+++ pypy/trunk/src/pypy/module/sysmodule.py	Fri May 30 13:16:30 2003
@@ -1,7 +1,32 @@
+from pypy.interpreter.baseobjspace import OperationError
 from pypy.interpreter.extmodule import *
 import sys
 
 class Sys(BuiltinModule):
     __pythonname__ = 'sys'
+
+    def __init__(self, space):
+        BuiltinModule.__init__(self, space)
+
+        import sys, os
+        import pypy
+
+        opd = os.path.dirname
+        
+        pypydir = opd(opd(os.path.abspath(pypy.__file__)))
+
+        self.path = appdata([p for p in sys.path if p != pypydir])        
+    
     stdout = appdata(sys.stdout)
-    displayhook = appdata(sys.displayhook)
+
+    def displayhook(self, w_x):
+        space = self.space
+        w = space.wrap
+        if w_x != space.w_None:
+            try:
+                print space.unwrap(self.space.str(w_x))
+            except OperationError:
+                print "! could not print", w_x
+            space.setitem(space.w_builtins, w('_'), w_x)
+    displayhook = appmethod(displayhook)
+    


More information about the Pypy-commit mailing list