[pypy-commit] pypy use-file-star-for-file: try another sys stdio init approach

bdkearns noreply at buildbot.pypy.org
Thu Sep 11 02:23:02 CEST 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: use-file-star-for-file
Changeset: r73433:9ed68e57bad0
Date: 2014-09-10 20:06 -0400
http://bitbucket.org/pypy/pypy/changeset/9ed68e57bad0/

Log:	try another sys stdio init approach

diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -29,12 +29,6 @@
         'maxsize'               : 'space.wrap(sys.maxint)',
         'byteorder'             : 'space.wrap(sys.byteorder)',
         'maxunicode'            : 'space.wrap(vm.MAXUNICODE)',
-        'stdin'                 : 'state.getio(space).w_stdin',
-        '__stdin__'             : 'state.getio(space).w_stdin',
-        'stdout'                : 'state.getio(space).w_stdout',
-        '__stdout__'            : 'state.getio(space).w_stdout',
-        'stderr'                : 'state.getio(space).w_stderr',
-        '__stderr__'            : 'state.getio(space).w_stderr',
         'pypy_objspaceclass'    : 'space.wrap(repr(space))',
         #'prefix'               : # added by pypy_initial_path() when it
         #'exec_prefix'          : # succeeds, pointing to trunk or /usr
@@ -105,7 +99,15 @@
 
     def startup(self, space):
         from pypy.module.sys.state import getio
-        getio(space).startup(space)
+        io = getio(space)
+        io.startup(space)
+
+        for k in ["stdin", "__stdin__"]:
+            space.setitem(self.w_dict, space.wrap(k), io.stdin)
+        for k in ["stdout", "__stdout__"]:
+            space.setitem(self.w_dict, space.wrap(k), io.stdout)
+        for k in ["stderr", "__stderr__"]:
+            space.setitem(self.w_dict, space.wrap(k), io.stderr)
 
         if space.config.translating and not we_are_translated():
             # don't get the filesystemencoding at translation time
diff --git a/pypy/module/sys/state.py b/pypy/module/sys/state.py
--- a/pypy/module/sys/state.py
+++ b/pypy/module/sys/state.py
@@ -41,15 +41,15 @@
 
         stdin = W_File(space)
         stdin.fdopenstream(i, "r", space.wrap("<stdin>"))
-        self.w_stdin = space.wrap(stdin)
+        self.stdin = stdin
 
         stdout = W_File(space)
         stdout.fdopenstream(o, "w", space.wrap("<stdout>"))
-        self.w_stdout = space.wrap(stdout)
+        self.stdout = stdout
 
         stderr = W_File(space)
         stderr.fdopenstream(e, "w", space.wrap("<stderr>"))
-        self.w_stderr = space.wrap(stderr)
+        self.stderr = stderr
 
 def getio(space):
     return space.fromcache(IOState)


More information about the pypy-commit mailing list