Commit d81f60fe authored by Jim Fulton's avatar Jim Fulton

Merge pull request #19 from zopefoundation/GH-16

Fix for #16

Thanks!
parents 8ef6f470 78fe684d
......@@ -5,6 +5,9 @@
4.0.1 (unreleased)
==================
- Fix POSKeyError during transaction.commit when after savepoint.rollback.
see https://github.com/zopefoundation/ZODB/issues/16
- Ensure that the pickler used in PyPy always has a ``persistent_id``
attribute (``inst_persistent_id`` is not present on the pure-Python
pickler). (PR #17)
......
......@@ -997,6 +997,7 @@ class Connection(ExportImport, object):
def readCurrent(self, ob):
assert ob._p_jar is self
assert ob._p_oid is not None and ob._p_serial is not None
if ob._p_serial != z64:
self._readCurrent[ob._p_oid] = ob._p_serial
# persistent.interfaces.IPersistentDatamanager
......
......@@ -17,6 +17,7 @@ from ZODB.POSException import ReadConflictError
from ZODB.POSException import TransactionFailedError
import doctest
from BTrees.OOBTree import OOBTree
import transaction
import unittest
import ZODB
......@@ -27,6 +28,7 @@ import ZODB.tests.util
class P(Persistent):
pass
class ZODBTests(ZODB.tests.util.TestCase):
def setUp(self):
......@@ -327,6 +329,28 @@ class ZODBTests(ZODB.tests.util.TestCase):
cn.close()
def checkSavepointRollbackAndReadCurrent(self):
'''
savepoint rollback after readcurrent was called on a new object
should not raise POSKeyError
'''
cn = self._db.open()
try:
transaction.begin()
root = cn.root()
added_before_savepoint = P()
root['added_before_savepoint'] = added_before_savepoint
sp = transaction.savepoint()
added_before_savepoint.btree = new_btree = OOBTree()
cn.add(new_btree)
new_btree['change_to_trigger_read_current'] = P()
sp.rollback()
transaction.commit()
self.assertTrue('added_before_savepoint' in root)
finally:
transaction.abort()
cn.close()
def checkFailingSavepointSticks(self):
cn = self._db.open()
rt = cn.root()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment