diff options
author | Pieter Mulder <pmulder@proigia.nl> | 2016-06-29 11:15:44 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-06-29 11:15:44 -0400 |
commit | 20fe9ad17131bb5a8b9c39b12b1d61a37cc9570a (patch) | |
tree | 39c355ca0923003af46089f9915e2792a0e66135 | |
parent | 7c74d702a9632a8c7264d6972e46985de3fb2487 (diff) | |
download | sqlalchemy-pr_github_286.tar.gz |
Fix #3728 Pickle of Properties object failspr_github_286
Change-Id: I01ebd425bbfe145747fea2edd0d2d412c74fd84d
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/286
-rw-r--r-- | lib/sqlalchemy/util/_collections.py | 4 | ||||
-rw-r--r-- | test/base/test_utils.py | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/sqlalchemy/util/_collections.py b/lib/sqlalchemy/util/_collections.py index c29b81f6a..2ae203d5c 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'] + self.__init__(state['_data']) def __getattr__(self, key): try: diff --git a/test/base/test_utils.py b/test/base/test_utils.py index fcb9a59a3..1339329e1 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -2256,3 +2256,13 @@ 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 protocol in -1, 0, 1, 2: + print(protocol) + s = util.pickle.dumps(props, protocol) + p = util.pickle.loads(s) + assert props._data == p._data |