summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/build/changelog/changelog_10.rst10
-rw-r--r--lib/sqlalchemy/util/_collections.py4
-rw-r--r--test/base/test_utils.py35
3 files changed, 47 insertions, 2 deletions
diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst
index 7a41731bf..defee6d06 100644
--- a/doc/build/changelog/changelog_10.rst
+++ b/doc/build/changelog/changelog_10.rst
@@ -20,6 +20,16 @@
.. change::
:tags: bug, sql
+ :tickets: 3728
+
+ Fixed bug whereby the ``__getstate__`` / ``__setstate__``
+ methods for sqlalchemy.util.Properties were
+ non-working due to the transition in the 1.0 series to ``__slots__``.
+ The issue potentially impacted some third-party applications.
+ Pull request courtesy Pieter Mulder.
+
+ .. change::
+ :tags: bug, sql
:tickets: 3724
:meth:`.FromClause.count` is pending deprecation for 1.1. This function
diff --git a/lib/sqlalchemy/util/_collections.py b/lib/sqlalchemy/util/_collections.py
index c29b81f6a..be5d1be44 100644
--- a/lib/sqlalchemy/util/_collections.py
+++ b/lib/sqlalchemy/util/_collections.py
@@ -200,10 +200,10 @@ class Properties(object):
self._data[key] = obj
def __getstate__(self):
- return {'_data': self.__dict__['_data']}
+ return {'_data': self._data}
def __setstate__(self, state):
- self.__dict__['_data'] = state['_data']
+ object.__setattr__(self, '_data', state['_data'])
def __getattr__(self, key):
try:
diff --git a/test/base/test_utils.py b/test/base/test_utils.py
index fcb9a59a3..7e2473dee 100644
--- a/test/base/test_utils.py
+++ b/test/base/test_utils.py
@@ -2256,3 +2256,38 @@ class TestClassProperty(fixtures.TestBase):
eq_(B.something, {'foo': 1, 'bazz': 2})
+class TestProperties(fixtures.TestBase):
+
+ def test_pickle(self):
+ data = {'hello': 'bla'}
+ props = util.Properties(data)
+
+ for loader, dumper in picklers():
+ s = dumper(props)
+ p = loader(s)
+
+ eq_(props._data, p._data)
+ eq_(props.keys(), p.keys())
+
+ def test_pickle_immuatbleprops(self):
+ data = {'hello': 'bla'}
+ props = util.Properties(data).as_immutable()
+
+ for loader, dumper in picklers():
+ s = dumper(props)
+ p = loader(s)
+
+ eq_(props._data, p._data)
+ eq_(props.keys(), p.keys())
+
+ def test_pickle_orderedprops(self):
+ data = {'hello': 'bla'}
+ props = util.OrderedProperties()
+ props.update(data)
+
+ for loader, dumper in picklers():
+ s = dumper(props)
+ p = loader(s)
+
+ eq_(props._data, p._data)
+ eq_(props.keys(), p.keys())