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 @@ ...@@ -5,6 +5,9 @@
4.0.1 (unreleased) 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`` - Ensure that the pickler used in PyPy always has a ``persistent_id``
attribute (``inst_persistent_id`` is not present on the pure-Python attribute (``inst_persistent_id`` is not present on the pure-Python
pickler). (PR #17) pickler). (PR #17)
......
...@@ -997,7 +997,8 @@ class Connection(ExportImport, object): ...@@ -997,7 +997,8 @@ class Connection(ExportImport, object):
def readCurrent(self, ob): def readCurrent(self, ob):
assert ob._p_jar is self assert ob._p_jar is self
assert ob._p_oid is not None and ob._p_serial is not None assert ob._p_oid is not None and ob._p_serial is not None
self._readCurrent[ob._p_oid] = ob._p_serial if ob._p_serial != z64:
self._readCurrent[ob._p_oid] = ob._p_serial
# persistent.interfaces.IPersistentDatamanager # persistent.interfaces.IPersistentDatamanager
########################################################################## ##########################################################################
......
...@@ -17,6 +17,7 @@ from ZODB.POSException import ReadConflictError ...@@ -17,6 +17,7 @@ from ZODB.POSException import ReadConflictError
from ZODB.POSException import TransactionFailedError from ZODB.POSException import TransactionFailedError
import doctest import doctest
from BTrees.OOBTree import OOBTree
import transaction import transaction
import unittest import unittest
import ZODB import ZODB
...@@ -27,6 +28,7 @@ import ZODB.tests.util ...@@ -27,6 +28,7 @@ import ZODB.tests.util
class P(Persistent): class P(Persistent):
pass pass
class ZODBTests(ZODB.tests.util.TestCase): class ZODBTests(ZODB.tests.util.TestCase):
def setUp(self): def setUp(self):
...@@ -327,6 +329,28 @@ class ZODBTests(ZODB.tests.util.TestCase): ...@@ -327,6 +329,28 @@ class ZODBTests(ZODB.tests.util.TestCase):
cn.close() 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): def checkFailingSavepointSticks(self):
cn = self._db.open() cn = self._db.open()
rt = cn.root() 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