Skip to content

Commit

Permalink
Fix infinite recursion when copying from a MappingStorage to a FileSt…
Browse files Browse the repository at this point in the history
…orage
  • Loading branch information
MatthewWilkes committed Mar 28, 2018
1 parent a6bedf8 commit a4de37c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ZODB/MappingStorage.py
Expand Up @@ -344,8 +344,8 @@ def __init__(self, tid, transaction, data):
self.extension = extension
self.data = data

_extension = property(lambda self: self._extension,
lambda self, v: setattr(self, '_extension', v),
_extension = property(lambda self: self.extension,
lambda self, v: setattr(self, 'extension', v),
)

def __iter__(self):
Expand Down
31 changes: 29 additions & 2 deletions src/ZODB/tests/testMappingStorage.py
Expand Up @@ -11,6 +11,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
from collections import namedtuple
import ZODB.MappingStorage
import unittest
import ZODB.tests.hexstorage
Expand Down Expand Up @@ -61,9 +62,35 @@ def setUp(self):
self._storage = ZODB.tests.hexstorage.HexStorage(
ZODB.MappingStorage.MappingStorage())

MockTransaction = namedtuple(
'transaction',
['user', 'description', 'extension']
)

class MappingStorageTransactionRecordTests(unittest.TestCase):

def setUp(self):
self._transaction_record = ZODB.MappingStorage.TransactionRecord(
0,
MockTransaction('user', 'description', 'extension'),
''
)

def check_set__extension(self):
self._transaction_record._extension = 'new'
self.assertEqual(self._transaction_record.extension, 'new')

def check_get__extension(self):
self.assertEqual(
self._transaction_record.extension,
self._transaction_record._extension
)

def test_suite():
suite = unittest.makeSuite(MappingStorageTests, 'check')
suite = unittest.makeSuite(MappingStorageHexTests, 'check')
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(MappingStorageTests, 'check'))
suite.addTest(unittest.makeSuite(MappingStorageHexTests, 'check'))
suite.addTest(unittest.makeSuite(MappingStorageTransactionRecordTests, 'check'))
return suite

if __name__ == "__main__":
Expand Down

0 comments on commit a4de37c

Please sign in to comment.