Skip to content

Pickling bug in ApiResponse #99

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

Closed
embray opened this issue Feb 20, 2023 · 0 comments · Fixed by #100
Closed

Pickling bug in ApiResponse #99

embray opened this issue Feb 20, 2023 · 0 comments · Fixed by #100

Comments

@embray
Copy link

embray commented Feb 20, 2023

The ApiResponse class has an unsafe __getattr__ (

def __getattr__(self, attr: str) -> Any:
) in the context of restoring from a pickled object.

When loading the object from a pickle, the unpickler tries to look up the __setstate__ attribute, but since self._body is not set yet either, this results in an infinite recursion.

Safest bet is probably just to define __getstate__ and __setstate__ on this class, e.g.

def __getstate__(self):
    return (self._body, self._meta)

def __setstate__(self, state):
    self._body, self._meta = state
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 a pull request may close this issue.

1 participant