Skip to content

Fix unpickling of CallbackRegistry on Py2. #7914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2017

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jan 22, 2017

In general, callbacks may not be pickled; thus, we simply recreate an
empty dictionary at unpickling. In order to ensure that __setstate__
(which just defers to __init__) is called, __getstate__ must
return a truthy value (for pickle protocol>=3, i.e. Py3, the
actual behavior is that __setstate__ will be called as long as
__getstate__ does not return None, but this is undocumented -- see
http://bugs.python.org/issue12290).

Closes #6048, #7902.

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Jan 22, 2017
@QuLogic
Copy link
Member

QuLogic commented Jan 22, 2017

There will be some conflicts with #7830; not sure which one to merge first.

In general, callbacks may not be pickled; thus, we simply recreate an
empty dictionary at unpickling.  In order to ensure that `__setstate__`
(which just defers to `__init__`) is called, `__getstate__` must
return a truthy value (for pickle protocol>=3, i.e. Py3, the
*actual* behavior is that `__setstate__` will be called as long as
`__getstate__` does not return `None`, but this is undocumented -- see
http://bugs.python.org/issue12290).
@anntzer anntzer force-pushed the callbackregistry-unpickling branch from e415ed1 to ef3072e Compare January 22, 2017 04:42
@codecov-io
Copy link

codecov-io commented Jan 22, 2017

Current coverage is 62.18% (diff: 100%)

Merging #7914 into master will not change coverage

@@             master      #7914   diff @@
==========================================
  Files           175        175          
  Lines         56125      56125          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits          34901      34901          
  Misses        21224      21224          
  Partials          0          0          

Powered by Codecov. Last update f41ef96...ef3072e

@anntzer
Copy link
Contributor Author

anntzer commented Jan 22, 2017

Not a problem anymore.

Copy link
Member

@NelleV NelleV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thanks @anntzer !

@NelleV NelleV merged commit 0223e27 into matplotlib:master Jan 24, 2017
NelleV added a commit that referenced this pull request Jan 24, 2017
Fix unpickling of CallbackRegistry on Py2.
@anntzer anntzer deleted the callbackregistry-unpickling branch January 24, 2017 07:38
@NelleV
Copy link
Member

NelleV commented Jan 24, 2017

Backported to v2.0.x by 5813452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants