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
multiprocessing adds built-in types to the global copyreg.dispatch_table #47600
Comments
The multiprocessing module modifies the global copyreg.dispatch_table to Here is an example of a behaviour change made by multiprocessing: >>> import pickle
>>> pickle.dumps(str.isalpha)
Traceback (most recent call last):
...
_pickle.PicklingError: Can't pickle <class 'method_descriptor'>:
attribute lookup builtins.method_descriptor failed
>>> import multiprocessing.util
>>> pickle.dumps(str.isalpha)
b'\x80\x03cbuiltins\ngetattr\nq\x00cbuiltins\nstr\nq\x01X\x07\x00\x00\x00isalphaq\x02\x86q\x03Rq\x04.' There was some discussion in bpo-558238 about allowing methods to be In addition, there is a bug in the method pickling support added by Python 2.6b1+ (trunk:64899:64900, Jul 13 2008, 13:33:02)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing.util, pickle
>>> class A(object):
... def foo(self): pass
...
>>> pickle.dumps(A().foo, 2)
'\x80\x02c__builtin__\ngetattr\nq\x00c__main__\nA\nq\x01)\x81q\x02}q\x03bU\x03fooq\x04\x86q\x05Rq\x06.'
>>> pickle.dumps(A.foo, 2)
'\x80\x02c__builtin__\ngetattr\nq\x00c__main__\nA\nq\x01U\x03fooq\x02\x86q\x03Rq\x04.'
Python 3.0b1+ (py3k:64876M, Jul 11 2008, 12:20:51)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing.util, pickle
>>> class A(object):
... def foo(self): pass
...
>>> pickle.dumps(A().foo, 2)
Traceback (most recent call last):
...
pickle.PicklingError: Can't pickle <class 'method'>: it's not found as
builtins.method
>>> pickle.dumps(A.foo, 2)
Traceback (most recent call last):
...
pickle.PicklingError: Can't pickle <function foo at 0xb7b1392c>: it's
not found as __main__.foo A better solution for the interprocess communication needs of |
Alexandre, this behavior no longer occurs in trunk, and a custom I am going to close this as fixed, but please reopen if there is continued |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: