[Zodb-checkins] SVN: ZODB/branches/tseaver-python_picklecache-2/src/persistent/ Enforce 8-octet requirement for _p_serial.
Tres Seaver
tseaver at palladion.com
Wed Feb 16 00:04:43 EST 2011
Log message for revision 120373:
Enforce 8-octet requirement for _p_serial.
Changed:
U ZODB/branches/tseaver-python_picklecache-2/src/persistent/pyPersistence.py
U ZODB/branches/tseaver-python_picklecache-2/src/persistent/tests/test_pyPersistence.py
-=-
Modified: ZODB/branches/tseaver-python_picklecache-2/src/persistent/pyPersistence.py
===================================================================
--- ZODB/branches/tseaver-python_picklecache-2/src/persistent/pyPersistence.py 2011-02-16 05:04:42 UTC (rev 120372)
+++ ZODB/branches/tseaver-python_picklecache-2/src/persistent/pyPersistence.py 2011-02-16 05:04:43 UTC (rev 120373)
@@ -125,6 +125,8 @@
if value is not None:
if not isinstance(value, SERIAL_TYPE):
raise ValueError('Invalid SERIAL type: %s' % value)
+ if len(value) != 8:
+ raise ValueError('SERIAL must be 8 octets')
self.__serial = value
def _del_serial(self):
Modified: ZODB/branches/tseaver-python_picklecache-2/src/persistent/tests/test_pyPersistence.py
===================================================================
--- ZODB/branches/tseaver-python_picklecache-2/src/persistent/tests/test_pyPersistence.py 2011-02-16 05:04:42 UTC (rev 120372)
+++ ZODB/branches/tseaver-python_picklecache-2/src/persistent/tests/test_pyPersistence.py 2011-02-16 05:04:43 UTC (rev 120373)
@@ -141,12 +141,24 @@
del inst._p_oid
self.assertRaises(ValueError, _test)
- def test_assign_p_serial_w_invalid_serial(self):
+ def test_assign_p_serial_w_invalid_type(self):
inst = self._makeOne()
def _test():
inst._p_serial = object()
self.assertRaises(ValueError, _test)
+ def test_assign_p_serial_too_short(self):
+ inst = self._makeOne()
+ def _test():
+ inst._p_serial = '\x01\x02\x03'
+ self.assertRaises(ValueError, _test)
+
+ def test_assign_p_serial_too_long(self):
+ inst = self._makeOne()
+ def _test():
+ inst._p_serial = '\x01\x02\x03' * 3
+ self.assertRaises(ValueError, _test)
+
def test_assign_p_serial_w_valid_serial(self):
SERIAL = '1' * 8
inst = self._makeOne()
More information about the Zodb-checkins
mailing list