Commits

Philip Jenvey committed 1a37ab1

fix __module__ on many _io types

Comments (0)

Files changed (6)

pypy/module/_io/interp_bufferedio.py

         space.warn("max_buffer_size is deprecated", space.w_DeprecationWarning)
 
 W_BufferedIOBase.typedef = TypeDef(
-    '_io._BufferedIOBase', W_IOBase.typedef,
+    '_BufferedIOBase', W_IOBase.typedef,
+    __module__ = "_io",
     __new__ = generic_new_descr(W_BufferedIOBase),
     read = interp2app(W_BufferedIOBase.read_w),
     read1 = interp2app(W_BufferedIOBase.read1_w),
                               'isatty'])
 
 W_BufferedRWPair.typedef = TypeDef(
-    '_io.BufferedRWPair', W_BufferedIOBase.typedef,
+    'BufferedRWPair', W_BufferedIOBase.typedef,
+    __module__ = "_io",
     __new__ = generic_new_descr(W_BufferedRWPair),
     __init__  = interp2app(W_BufferedRWPair.descr_init),
     __getstate__ = interp2app(W_BufferedRWPair.getstate_w),

pypy/module/_io/interp_bytesio.py

 
 W_BytesIO.typedef = TypeDef(
     'BytesIO', W_BufferedIOBase.typedef,
+    __module__ = "_io",
     __new__ = generic_new_descr(W_BytesIO),
     __init__  = interp2app(W_BytesIO.descr_init),
 

pypy/module/_io/interp_fileio.py

 
 W_FileIO.typedef = TypeDef(
     'FileIO', W_RawIOBase.typedef,
+    __module__ = "_io",
     __new__  = interp2app(W_FileIO.descr_new.im_func),
     __init__  = interp2app(W_FileIO.descr_init),
     __repr__ = interp2app(W_FileIO.repr_w),

pypy/module/_io/interp_iobase.py

 
 W_IOBase.typedef = TypeDef(
     '_IOBase',
+    __module__ = "_io",
     __new__ = generic_new_descr(W_IOBase),
     __enter__ = interp2app(W_IOBase.enter_w),
     __exit__ = interp2app(W_IOBase.exit_w),
 
 W_RawIOBase.typedef = TypeDef(
     '_RawIOBase', W_IOBase.typedef,
+    __module__ = "_io",
     __new__ = generic_new_descr(W_RawIOBase),
 
     read = interp2app(W_RawIOBase.read_w),

pypy/module/_io/interp_textio.py

 
 W_IncrementalNewlineDecoder.typedef = TypeDef(
     'IncrementalNewlineDecoder',
+    __module__ = "_io",
     __new__ = generic_new_descr(W_IncrementalNewlineDecoder),
     __init__  = interp2app(W_IncrementalNewlineDecoder.descr_init),
 
 
 W_TextIOBase.typedef = TypeDef(
     '_TextIOBase', W_IOBase.typedef,
+    __module__ = "_io",
     __new__ = generic_new_descr(W_TextIOBase),
 
     read = interp2app(W_TextIOBase.read_w),

pypy/module/_io/test/test_io.py

             for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
                 with _io.open(self.tmpfile, **kwargs) as f:
                     raises(TypeError, pickle.dumps, f, protocol)
+
+    def test_mod(self):
+        import _io
+        assert all(t.__module__ == '_io' for t in dir(_io)
+                   if isinstance(t, type))