Author: Philip Jenvey <[email protected]>
Branch:
Changeset: r70125:f15f9a524509
Date: 2014-03-20 10:42 -0700
http://bitbucket.org/pypy/pypy/changeset/f15f9a524509/
Log: backport 9813b8a36001 from py3k: cache UnsupportedOperation but this
time to avoid potential module reloading issues
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
@@ -8,6 +8,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',
@@ -26,16 +28,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_autoflusher
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)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit