Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r61461:9813b8a36001
Date: 2013-02-19 10:57 -0800
http://bitbucket.org/pypy/pypy/changeset/9813b8a36001/
Log: cache UnsupportedOperation to avoid issues w/ io being frozen, fix
__module__ again
diff --git a/pypy/module/_io/__init__.py b/pypy/module/_io/__init__.py
--- a/pypy/module/_io/__init__.py
+++ b/pypy/module/_io/__init__.py
@@ -9,6 +9,8 @@
interpleveldefs = {
'DEFAULT_BUFFER_SIZE': 'space.wrap(interp_iobase.DEFAULT_BUFFER_SIZE)',
'BlockingIOError': 'interp_io.W_BlockingIOError',
+ 'UnsupportedOperation':
+ 'space.fromcache(interp_io.Cache).w_unsupportedoperation',
'_IOBase': 'interp_iobase.W_IOBase',
'_RawIOBase': 'interp_iobase.W_RawIOBase',
'_BufferedIOBase': 'interp_bufferedio.W_BufferedIOBase',
@@ -27,16 +29,6 @@
'IncrementalNewlineDecoder':
'interp_textio.W_IncrementalNewlineDecoder',
}
- def init(self, space):
- MixedModule.init(self, space)
- w_UnsupportedOperation = space.call_function(
- space.w_type,
- space.wrap('UnsupportedOperation'),
- space.newtuple([space.w_ValueError, space.w_IOError]),
- space.newdict())
- space.setattr(self, space.wrap('UnsupportedOperation'),
- w_UnsupportedOperation)
-
def shutdown(self, space):
# at shutdown, flush all open streams. Ignore I/O errors.
from pypy.module._io.interp_iobase import get_autoflushher
diff --git a/pypy/module/_io/interp_io.py b/pypy/module/_io/interp_io.py
--- a/pypy/module/_io/interp_io.py
+++ b/pypy/module/_io/interp_io.py
@@ -10,6 +10,12 @@
from rpython.rtyper.module.ll_os_stat import STAT_FIELD_TYPES
+class Cache:
+ def __init__(self, space):
+ self.w_unsupportedoperation = space.new_exception_class(
+ "io.UnsupportedOperation",
+ space.newtuple([space.w_ValueError, space.w_IOError]))
+
class W_BlockingIOError(W_IOError):
def __init__(self, space):
W_IOError.__init__(self, space)
@@ -22,6 +28,7 @@
W_BlockingIOError.typedef = TypeDef(
'BlockingIOError', W_IOError.typedef,
+ __module__ = 'io',
__doc__ = ("Exception raised when I/O would block "
"on a non-blocking I/O stream"),
__new__ = generic_new_descr(W_BlockingIOError),
diff --git a/pypy/module/_io/test/test_io.py b/pypy/module/_io/test/test_io.py
--- a/pypy/module/_io/test/test_io.py
+++ b/pypy/module/_io/test/test_io.py
@@ -373,5 +373,5 @@
def test_mod(self):
import _io
- assert all(t.__module__ == '_io' for t in dir(_io)
+ assert all(t.__module__ in ('io', '_io') for t in vars(_io).values()
if isinstance(t, type))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit