[issue11771] hashlib object cannot be pickled

Gregory P. Smith report at bugs.python.org
Tue Jul 1 19:29:48 CEST 2014


Gregory P. Smith added the comment:

Please be constructive.

There is no way to implement generic pickling for hash objects that would work across all implementations.  

The underlying code implementing each function is free to store its internal state however it wants and does not provide an API to get at it or any standard representation of it.

Sure, you could hack things up and allow a specific version and build of openssl's EVP hashes to dump their state and restore it for use in another process running that same specific version and build of openssl (as would likely be the case for multiprocessing use) just as you could for any other implementation of a hash function such as the builtin libtomcrypt versions.  But this is not portable between compilations using different implementations of the hash algorithm.  That is not what someone using pickle would ever expect.

Public APIs to access the internal state of hash functions do not exist because it is not a common thing for people to do.

hashlib isn't going to support this unless someone contributes a very solid patch with tests that handles all of the compatibility issues in a friendly maintainable manner.

----------
stage:  -> resolved
type:  -> enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11771>
_______________________________________


More information about the Python-bugs-list mailing list