[Zodb-checkins] SVN: ZODB/branches/tseaver-python_picklecache-2/src/persistent/ Return expected all-zeros value when _p_serial not set.
Tres Seaver
tseaver at palladion.com
Wed Feb 16 00:04:36 EST 2011
Log message for revision 120367:
Return expected all-zeros value when _p_serial not set.
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:34 UTC (rev 120366)
+++ ZODB/branches/tseaver-python_picklecache-2/src/persistent/pyPersistence.py 2011-02-16 05:04:35 UTC (rev 120367)
@@ -30,6 +30,8 @@
else:
OID_TYPE = SERIAL_TYPE = bytes
+_INITIAL_SERIAL = '\x00' * 8
+
# Bitwise flags
_CHANGED = 0x0001
_STICKY = 0x0002
@@ -109,7 +111,9 @@
# _p_serial: see IPersistent.
def _get_serial(self):
- return self.__serial
+ if self.__serial is not None:
+ return self.__serial
+ return _INITIAL_SERIAL
def _set_serial(self, value):
if value is not None:
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:34 UTC (rev 120366)
+++ ZODB/branches/tseaver-python_picklecache-2/src/persistent/tests/test_pyPersistence.py 2011-02-16 05:04:35 UTC (rev 120367)
@@ -70,7 +70,7 @@
inst = self._makeOne()
self.assertEqual(inst._p_jar, None)
self.assertEqual(inst._p_oid, None)
- self.assertEqual(inst._p_serial, None)
+ self.assertEqual(inst._p_serial, '\x00' * 8)
self.assertEqual(inst._p_changed, None)
self.assertEqual(inst._p_sticky, False)
@@ -129,8 +129,16 @@
inst._p_serial = SERIAL
self.assertEqual(inst._p_serial, SERIAL)
inst._p_serial = None
- self.assertEqual(inst._p_serial, None)
+ self.assertEqual(inst._p_serial, '\x00' * 8)
+ def test_delete_p_serial(self):
+ SERIAL = '1' * 8
+ inst = self._makeOne()
+ inst._p_serial = SERIAL
+ self.assertEqual(inst._p_serial, SERIAL)
+ del(inst._p_serial)
+ self.assertEqual(inst._p_serial, '\x00' * 8)
+
def test_query_p_changed(self):
inst = self._makeOne()
self.assertEqual(inst._p_changed, None)
@@ -642,7 +650,7 @@
self.assertRaises(ValueError, inst.__setstate__, {'bogus': 1})
self.assertEqual(inst._p_jar, None)
self.assertEqual(inst._p_oid, None)
- self.assertEqual(inst._p_serial, None)
+ self.assertEqual(inst._p_serial, '\x00' * 8)
self.assertEqual(inst._p_changed, None)
self.assertEqual(inst._p_sticky, False)
More information about the Zodb-checkins
mailing list