-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Max recursion during unpickling with a proxy object #133015
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
Comments
How does it fare with a plain queue.Queue? does it fail as well? |
Just tested it and it appears to work as intended.
|
This happens during unpickling. Here's a simplified reproducer without multiprocessing.Queue: import pickle
class Wrapper:
def __init__(self, x):
self.x = x
def __getattr__(self, name):
return getattr(self.x, name)
b = pickle.dumps(Wrapper("foo"))
pickle.loads(b) # <-- recursion here |
The recursion happens during this call of |
|
Ya, the Python implementation is also affected (recurses in the "same spot" here). However, looking at the pickle docs, this seems to be expected behavior. The docs have this warning about relying on
So, I think this can be considered a bug in the user code and not something CPython needs to fix. |
Indeed, thanks for pointing out the docs. Is there a way to determine which methods can be called during unpickling (by default)? if not, let's close this issue; otherwise, let's improve the wording in the docs (to me, it seems as if we say "we know of some methods but others can also be called so up to you to find which ones") |
Bug report
Bug description:
Description of Problem
A wrapper class was needed to wrap an underlying object while exposing the underlying object's attributes. https://stackoverflow.com/questions/68926132/creation-of-a-class-wrapper-in-python
When creating a wrapper object for an object to be placed on a multiprocessing queue, if the wrapper object overrides the getattr method, and the object is retrieved from the queue, a max recursion depth error is observed. The expected behavior was for the wrapper object to be returned and have the underlying object exposed in the process that was handling the object.
Example Snippet
CPython versions tested on:
3.11
Operating systems tested on:
Linux, Windows
The text was updated successfully, but these errors were encountered: