[pypy-svn] r79244 - pypy/branch/fast-forward/pypy/module/_io
afa at codespeak.net
afa at codespeak.net
Thu Nov 18 14:07:07 CET 2010
Author: afa
Date: Thu Nov 18 14:07:05 2010
New Revision: 79244
Modified:
pypy/branch/fast-forward/pypy/module/_io/interp_bufferedio.py
pypy/branch/fast-forward/pypy/module/_io/interp_iobase.py
Log:
Add a sanity check (CPython has the same)
and try to clear weakrefs correctly
Modified: pypy/branch/fast-forward/pypy/module/_io/interp_bufferedio.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/interp_bufferedio.py (original)
+++ pypy/branch/fast-forward/pypy/module/_io/interp_bufferedio.py Thu Nov 18 14:07:05 2010
@@ -499,6 +499,10 @@
if space.is_w(w_size, space.w_None):
raise BlockingIOError()
size = space.int_w(w_size)
+ if size < 0 or size > length:
+ raise OperationError(space.w_IOError, space.wrap(
+ "raw readinto() returned invalid length %d "
+ "(should have been between 0 and %d)" % (size, length)))
if self.abs_pos != -1:
self.abs_pos += size
return size
@@ -843,7 +847,8 @@
raise
def __del__(self):
- pass # no not close the files
+ self.clear_all_weakrefs()
+ # Don't call the base __del__: do not close the files!
# forward to reader
for method in ['read', 'peek', 'read1', 'readinto', 'readable']:
Modified: pypy/branch/fast-forward/pypy/module/_io/interp_iobase.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/interp_iobase.py (original)
+++ pypy/branch/fast-forward/pypy/module/_io/interp_iobase.py Thu Nov 18 14:07:05 2010
@@ -57,6 +57,7 @@
return False
def __del__(self):
+ self.clear_all_weakrefs()
space = self.space
w_closed = space.findattr(self, space.wrap('closed'))
try:
More information about the Pypy-commit
mailing list