[pypy-svn] r49405 - in pypy/branch/pypy-interp-file: interpreter module/_file module/sys

arigo at codespeak.net arigo at codespeak.net
Wed Dec 5 19:36:24 CET 2007


Author: arigo
Date: Wed Dec  5 19:36:24 2007
New Revision: 49405

Modified:
   pypy/branch/pypy-interp-file/interpreter/baseobjspace.py
   pypy/branch/pypy-interp-file/module/_file/interp_file.py
   pypy/branch/pypy-interp-file/module/sys/state.py
Log:
module/_file tests pass now -- which just shows that they're incomplete :-/


Modified: pypy/branch/pypy-interp-file/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/pypy-interp-file/interpreter/baseobjspace.py	(original)
+++ pypy/branch/pypy-interp-file/interpreter/baseobjspace.py	Wed Dec  5 19:36:24 2007
@@ -214,6 +214,7 @@
         w_exitfunc = self.sys.getdictvalue_w(self, 'exitfunc')
         if w_exitfunc is not None:
             self.call_function(w_exitfunc)
+        from pypy.interpreter.module import Module
         for w_modname in self.unpackiterable(
                                 self.sys.get('builtin_module_names')):
             modname = self.str_w(w_modname)

Modified: pypy/branch/pypy-interp-file/module/_file/interp_file.py
==============================================================================
--- pypy/branch/pypy-interp-file/module/_file/interp_file.py	(original)
+++ pypy/branch/pypy-interp-file/module/_file/interp_file.py	Wed Dec  5 19:36:24 2007
@@ -159,6 +159,12 @@
     #
     # The 'file_' methods are the one exposed to app-level.
 
+    def file_fdopen(self, fd, mode="r", buffering=-1):
+        try:
+            self.direct_fdopen(fd, mode, buffering)
+        except StreamErrors, e:
+            raise wrap_streamerror(self.space, e)
+
     _exposed_method_names = []
     _exposed_classmethod_names = []
 
@@ -274,10 +280,7 @@
 def descr_file_fdopen(space, w_subtype, fd, mode='r', buffering=-1):
     file = space.allocate_instance(W_File, w_subtype)
     W_File.__init__(file, space)
-    try:
-        file.direct_fdopen(fd, mode, buffering)
-    except StreamErrors, e:
-        raise wrap_streamerror(space, e)
+    file.file_fdopen(fd, mode, buffering)
     return space.wrap(file)
 descr_file_fdopen.unwrap_spec = [ObjSpace, W_Root, int, str, int]
 

Modified: pypy/branch/pypy-interp-file/module/sys/state.py
==============================================================================
--- pypy/branch/pypy-interp-file/module/sys/state.py	(original)
+++ pypy/branch/pypy-interp-file/module/sys/state.py	Wed Dec  5 19:36:24 2007
@@ -76,25 +76,23 @@
 
 class IOState:
     def __init__(self, space):
+        from pypy.module._file.interp_file import W_File
         self.space = space
 
-        w_fdopen = space.getattr(space.builtin.get('file'),
-                                 space.wrap("fdopen"))
-        self.w_stdin = space.call_function(
-            w_fdopen, space.wrap(0), space.wrap("r"),
-            space.wrap(1))
-        space.setattr(self.w_stdin, space.wrap("_name"),
-                      space.wrap("<stdin>"))
-        self.w_stdout = space.call_function(
-            w_fdopen, space.wrap(1), space.wrap("w"),
-            space.wrap(1))
-        space.setattr(self.w_stdout, space.wrap("_name"),
-                      space.wrap("<stdout>"))
-        self.w_stderr = space.call_function(
-            w_fdopen, space.wrap(2), space.wrap("w"),
-            space.wrap(0))
-        space.setattr(self.w_stderr, space.wrap("_name"),
-                      space.wrap("<stderr>"))
+        stdin = W_File(space)
+        stdin.file_fdopen(0, "r", 1)
+        stdin.name = '<stdin>'
+        self.w_stdin = space.wrap(stdin)
+
+        stdout = W_File(space)
+        stdout.file_fdopen(1, "w", 1)
+        stdout.name = '<stdout>'
+        self.w_stdout = space.wrap(stdout)
+
+        stderr = W_File(space)
+        stderr.file_fdopen(2, "w", 0)
+        stderr.name = '<stderr>'
+        self.w_stderr = space.wrap(stderr)
 
 def getio(space):
     return space.fromcache(IOState)



More information about the Pypy-commit mailing list