[pypy-svn] r77581 - in pypy/branch/fast-forward/pypy: doc/config module/_io module/_io/test

afa at codespeak.net afa at codespeak.net
Mon Oct 4 19:24:47 CEST 2010


Author: afa
Date: Mon Oct  4 19:24:45 2010
New Revision: 77581

Added:
   pypy/branch/fast-forward/pypy/doc/config/objspace.usemodules._io.txt   (contents, props changed)
   pypy/branch/fast-forward/pypy/module/_io/   (props changed)
   pypy/branch/fast-forward/pypy/module/_io/__init__.py   (contents, props changed)
   pypy/branch/fast-forward/pypy/module/_io/interp_io.py   (contents, props changed)
   pypy/branch/fast-forward/pypy/module/_io/test/   (props changed)
   pypy/branch/fast-forward/pypy/module/_io/test/test_io.py   (contents, props changed)
Log:
Add minimal stub of a _io module,
enough to "import io" though.


Added: pypy/branch/fast-forward/pypy/doc/config/objspace.usemodules._io.txt
==============================================================================
--- (empty file)
+++ pypy/branch/fast-forward/pypy/doc/config/objspace.usemodules._io.txt	Mon Oct  4 19:24:45 2010
@@ -0,0 +1,2 @@
+Use the '_io module.
+Used by the 'io' standard lib module. This module is expected to be working and is included by default.

Added: pypy/branch/fast-forward/pypy/module/_io/__init__.py
==============================================================================
--- (empty file)
+++ pypy/branch/fast-forward/pypy/module/_io/__init__.py	Mon Oct  4 19:24:45 2010
@@ -0,0 +1,30 @@
+from pypy.interpreter.mixedmodule import MixedModule
+import sys
+
+class Module(MixedModule):
+
+    appleveldefs = {
+        }
+
+    interpleveldefs = {
+        'DEFAULT_BUFFER_SIZE': 'space.wrap(interp_io.DEFAULT_BUFFER_SIZE)',
+        'BlockingIOError': 'interp_io.W_BlockingIOError',
+        '_IOBase': 'interp_io.W_IOBase',
+        '_RawIOBase': 'interp_io.W_RawIOBase',
+        '_BufferedIOBase': 'interp_io.W_BufferedIOBase',
+        '_TextIOBase': 'interp_io.W_TextIOBase',
+
+        'FileIO': 'interp_io.W_FileIO',
+        'BytesIO': 'interp_io.W_BytesIO',
+        'StringIO': 'interp_io.W_StringIO',
+        'BufferedReader': 'interp_io.W_BufferedReader',
+        'BufferedWriter': 'interp_io.W_BufferedWriter',
+        'BufferedRWPair': 'interp_io.W_BufferedRWPair',
+        'BufferedRandom': 'interp_io.W_BufferedRandom',
+        'TextIOWrapper': 'interp_io.W_TextIOWrapper',
+        }
+
+    def startup(self, space):
+        for name in """UnsupportedOperation open IncrementalNewlineDecoder 
+                    """.split():
+            space.setattr(self, space.wrap(name), space.w_None)

Added: pypy/branch/fast-forward/pypy/module/_io/interp_io.py
==============================================================================
--- (empty file)
+++ pypy/branch/fast-forward/pypy/module/_io/interp_io.py	Mon Oct  4 19:24:45 2010
@@ -0,0 +1,94 @@
+from pypy.interpreter.baseobjspace import ObjSpace, Wrappable
+from pypy.interpreter.typedef import TypeDef, interp_attrproperty
+from pypy.module.exceptions.interp_exceptions import W_IOError
+
+DEFAULT_BUFFER_SIZE = 8192
+
+
+class W_BlockingIOError(W_IOError):
+    def __init__(self, space):
+        W_IOError.__init__(self, space)
+        self.written = 0
+
+    def descr_init(self, space, w_errno, w_strerror, written=0):
+        W_IOError.descr_init(self, space, [w_errno, w_strerror])
+        self.written = written
+
+W_BlockingIOError.typedef = TypeDef(
+    'BlockingIOError',
+    __doc__ = ("Exception raised when I/O would block "
+               "on a non-blocking I/O stream"),
+    characters_written = interp_attrproperty('written', W_BlockingIOError),
+    )
+
+class W_IOBase(Wrappable):
+    pass
+W_IOBase.typedef = TypeDef(
+    '_IOBase',
+    )
+
+class W_RawIOBase(W_IOBase):
+    pass
+W_RawIOBase.typedef = TypeDef(
+    '_RawIOBase', W_IOBase.typedef,
+    )
+
+class W_BufferedIOBase(W_IOBase):
+    pass
+W_BufferedIOBase.typedef = TypeDef(
+    '_BufferedIOBase', W_IOBase.typedef,
+    )
+
+class W_TextIOBase(W_IOBase):
+    pass
+W_TextIOBase.typedef = TypeDef(
+    '_TextIOBase', W_IOBase.typedef,
+    )
+
+class W_FileIO(W_RawIOBase):
+    pass
+W_FileIO.typedef = TypeDef(
+    'FileIO', W_RawIOBase.typedef,
+    )
+
+class W_BytesIO(W_BufferedIOBase):
+    pass
+W_BytesIO.typedef = TypeDef(
+    'BytesIO', W_BufferedIOBase.typedef,
+    )
+
+class W_StringIO(W_TextIOBase):
+    pass
+W_StringIO.typedef = TypeDef(
+    'StringIO', W_TextIOBase.typedef,
+    )
+
+class W_BufferedReader(W_BufferedIOBase):
+    pass
+W_BufferedReader.typedef = TypeDef(
+    'BufferedReader', W_BufferedIOBase.typedef,
+    )
+
+class W_BufferedWriter(W_BufferedIOBase):
+    pass
+W_BufferedWriter.typedef = TypeDef(
+    'BufferedWriter', W_BufferedIOBase.typedef,
+    )
+
+class W_BufferedRWPair(W_BufferedIOBase):
+    pass
+W_BufferedRWPair.typedef = TypeDef(
+    'BufferedRWPair', W_BufferedIOBase.typedef,
+    )
+
+class W_BufferedRandom(W_BufferedIOBase):
+    pass
+W_BufferedRandom.typedef = TypeDef(
+    'BufferedRandom', W_BufferedIOBase.typedef,
+    )
+
+class W_TextIOWrapper(W_TextIOBase):
+    pass
+W_TextIOWrapper.typedef = TypeDef(
+    'TextIOWrapper', W_TextIOBase.typedef,
+    )

Added: pypy/branch/fast-forward/pypy/module/_io/test/test_io.py
==============================================================================
--- (empty file)
+++ pypy/branch/fast-forward/pypy/module/_io/test/test_io.py	Mon Oct  4 19:24:45 2010
@@ -0,0 +1,8 @@
+from pypy.conftest import gettestobjspace
+
+class AppTestIoModule:
+    def setup_class(cls):
+        cls.space = gettestobjspace(usemodules=['_io'])
+
+    def test_import(self):
+        import io



More information about the Pypy-commit mailing list