PicklingError with md5.md5() object Von: Ulli Stein <mennosimons at gmx.net> Datum: Dienstag, 24. September 2002 17:03:09 Gruppen: comp.lang.python Folgenachricht an: mennosimons at gmx.net Keine Referenzen
Gerhard Häring
gerhard.haering at gmx.de
Tue Sep 24 13:18:27 EDT 2002
Ulli Stein wrote in comp.lang.python:
> Hi,
>
> while trying to pickle a md5 instance I get the following error:
>
>>>> import cPickle, md5
>>>> f=open("/tmp/t", "w")
>>>> p = cPickle.Pickler(f)
>>>> m=md5.md5()
>>>> p.dump(m)
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> cPickle.UnpickleableError: Cannot pickle <type 'md5.md5'> objects
>
>
> What should I do?
If you really need this, you'll probably have to patch md5 (and for
additional bonus points, sha and hmac, too) to support pickling. I
think, however, that this will be far from a trivial task, as you'll
have to dig through the internals of the MD5_CTX struct.
Do you really need to pickle md5 objects? I currently can only imagine
use cases where pickling full digests (from the .digest() or
.hexdigest() methods) makes sense. Do you really need to pickle
half-computed digests?
-- Gerhard
More information about the Python-list
mailing list