From 7f6944fb6c652bd802b7cd5e137c0be832f93d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Dietrich?= Date: Fri, 6 Feb 2015 16:24:21 +0100 Subject: [PATCH] Fix unpickling/__setstate__ in TransformNode --- lib/matplotlib/tests/test_transforms.py | 11 +++++++++++ lib/matplotlib/transforms.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_transforms.py b/lib/matplotlib/tests/test_transforms.py index c138b5937db9..a6f4b447af58 100644 --- a/lib/matplotlib/tests/test_transforms.py +++ b/lib/matplotlib/tests/test_transforms.py @@ -1,6 +1,7 @@ from __future__ import (absolute_import, division, print_function, unicode_literals) +import pickle import six from six.moves import xrange, zip @@ -502,6 +503,16 @@ def test_log_transform(): ax.transData.transform((1,1)) +@cleanup +def test_unpickling_transformnode(): + # Before matplotlib 1.4.2 unpickling a polar plot would throw an + # AttributeError + ax = plt.subplot(111, polar=True) + fig = plt.gcf() + pfig = pickle.dumps(fig) + fig2 = pickle.loads(pfig) + + if __name__=='__main__': import nose nose.runmodule(argv=['-s','--with-doctest'], exit=False) diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py index 91457366dbba..717c0f7f9faa 100644 --- a/lib/matplotlib/transforms.py +++ b/lib/matplotlib/transforms.py @@ -115,7 +115,7 @@ def __getstate__(self): def __setstate__(self, data_dict): self.__dict__ = data_dict # turn the normal dictionary back into a WeakValueDictionary - self._parents = WeakValueDictionary(self._parents) + self._parents = WeakValueDictionary(self.__dict__['_parents']) def __copy__(self, *args): raise NotImplementedError(