[Jython-checkins] jython: Fix regressions in _jyio following lib 2.7 update
jeff.allen
jython-checkins at python.org
Fri Mar 15 01:17:24 CET 2013
http://hg.python.org/jython/rev/039dba919d92
changeset: 7085:039dba919d92
user: Jeff Allen <ja...py at farowl.co.uk>
date: Fri Mar 15 00:01:22 2013 +0000
summary:
Fix regressions in _jyio following lib 2.7 update
test.test_memoryio changed to match changes in _pyio.py. Our _jyio.py
and local version of test_memoryio were upgraded to correspond.
(TextIOWrapper and BytesIO gain tests for closed.)
files:
Lib/_jyio.py | 14 ++++++++++----
Lib/test/test_memoryio.py | 16 +++++++++++++---
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/Lib/_jyio.py b/Lib/_jyio.py
--- a/Lib/_jyio.py
+++ b/Lib/_jyio.py
@@ -405,12 +405,15 @@
return pos
def readable(self):
+ self._checkClosed()
return True
def writable(self):
+ self._checkClosed()
return True
def seekable(self):
+ self._checkClosed()
return True
@@ -1080,6 +1083,7 @@
def seekable(self):
self._checkInitialized() # Jython: to forbid use in an invalid state
+ self._checkClosed()
return self._seekable
def readable(self):
@@ -1097,10 +1101,12 @@
def close(self):
if self.buffer is not None and not self.closed:
- # Jython difference: flush and close via super.
- # Sets __closed for quick _checkClosed().
- super(TextIOWrapper, self).close()
- self.buffer.close()
+ try:
+ # Jython difference: flush and close via super.
+ # Sets __closed for quick _checkClosed().
+ super(TextIOWrapper, self).close()
+ finally:
+ self.buffer.close()
# Jython difference: @property closed(self) inherited from _IOBase.__closed
diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py
--- a/Lib/test/test_memoryio.py
+++ b/Lib/test/test_memoryio.py
@@ -328,9 +328,9 @@
self.assertEqual(memio.isatty(), False)
self.assertEqual(memio.closed, False)
memio.close()
- self.assertEqual(memio.writable(), True)
- self.assertEqual(memio.readable(), True)
- self.assertEqual(memio.seekable(), True)
+ self.assertRaises(ValueError, memio.writable)
+ self.assertRaises(ValueError, memio.readable)
+ self.assertRaises(ValueError, memio.seekable)
self.assertRaises(ValueError, memio.isatty)
self.assertEqual(memio.closed, True)
@@ -655,6 +655,16 @@
memio.close()
self.assertRaises(ValueError, memio.__setstate__, (b"closed", 0, None))
+ check_sizeof = support.check_sizeof
+
+ @support.cpython_only
+ def test_sizeof(self):
+ basesize = support.calcobjsize(b'P2PP2P')
+ check = self.check_sizeof
+ self.assertEqual(object.__sizeof__(io.BytesIO()), basesize)
+ check(io.BytesIO(), basesize )
+ check(io.BytesIO(b'a'), basesize + 1 + 1 )
+ check(io.BytesIO(b'a' * 1000), basesize + 1000 + 1 )
class CStringIOTest(PyStringIOTest):
ioclass = io.StringIO
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list