Author: Brian Kearns <[email protected]>
Branch: use-file-star-for-file
Changeset: r73422:1899f1699c85
Date: 2014-09-10 18:24 -0400
http://bitbucket.org/pypy/pypy/changeset/1899f1699c85/
Log: another approach for sys io init
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
@@ -104,9 +104,6 @@
}
def startup(self, space):
- from pypy.module.sys.state import getio
- getio(space).startup(space)
-
if space.config.translating and not we_are_translated():
# don't get the filesystemencoding at translation time
assert self.filesystemencoding is None
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
@@ -31,9 +31,15 @@
class IOState:
def __init__(self, space):
- pass
+ self._cleanup_()
+
+ def _cleanup_(self):
+ self.w_stdin = self.w_stdout = self.w_stderr = None
def startup(self, space):
+ if self.w_stdout is not None:
+ return
+
from pypy.module._file.interp_file import W_File
stdin = W_File(space)
@@ -52,7 +58,9 @@
self.w_stderr = space.wrap(stderr)
def getio(space):
- return space.fromcache(IOState)
+ io = space.fromcache(IOState)
+ io.startup(space)
+ return io
def pypy_getudir(space):
"""NOT_RPYTHON
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit