Uh oh!
There was an error while loading. Please reload this page.
bpo-41052: Optout serialization/deserialization for blake2s/b - #22189
bpo-41052: Optout serialization/deserialization for blake2s/b#22189corona10 wants to merge 1 commit into
Conversation
corona10
commented
Sep 10, 2020
Before heap types, serialization/deserialization was failed. |
| _blake2_blake2s___reduce___impl(BLAKE2sObject *self) | ||
| /*[clinic end generated code: output=fb085f3da88f0c39 input=49898c2f1ef1ff74]*/ | ||
| { | ||
| PyErr_Format(PyExc_TypeError, |
There was a problem hiding this comment.
@vstinner This function is very redundant with this issue.
Do you have any ideas with better solution?
There was a problem hiding this comment.
I don't think that exposing it to the public is the proper way.
It's should be a kind of internal utility routine.
| { | ||
| PyErr_Format(PyExc_TypeError, | ||
| "cannot pickle %s object", | ||
| Py_TYPE(self)->tp_name); |
There was a problem hiding this comment.
Rather than having to copy/paste such code in each type, would it be possible to have a protocol like:
class NotHashable:
__hash__ = None
obj = NotHashable()
hash(obj)
This code raises TypeError: unhashable type: 'NotHashable'.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
By default most extension types are not serializable. blake2b is not serializable. Why is it needed to add explicit __reduce__ method?
master (after #21856)Python3.10.0a0 (heads/master:f76d894dc5, Sep102020, 23:26:39)
[Clang11.0.0 (clang-1100.0.33.12)] ondarwinType"help", "copyright", "credits"or"license"formoreinformation.
>>>importpickle>>>import_blake2>>>pickle.dumps(_blake2.blake2s(), 0)
b'ccopy_reg\n_reconstructor\np0\n(c_blake2\nblake2s\np1\nc__builtin__\nobject\np2\nNtp3\nRp4\n.'>>>pickle.dumps(_blake2.blake2s(), 1)
b'ccopy_reg\n_reconstructor\nq\x00(c_blake2\nblake2s\nq\x01c__builtin__\nobject\nq\x02Ntq\x03Rq\x04.'before>>>import_blake2>>>importpickle>>>pickle.dumps(_blake2.blake2s(), 0)
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/copyreg.py", line65, in_reduce_exraiseTypeError("can't pickle %s objects"%base.__name__)
TypeError: can'tpickleblake2sobjects>>>pickle.dumps(_blake2.blake2s(), 1)
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/copyreg.py", line65, in_reduce_exraiseTypeError("can't pickle %s objects"%base.__name__)
TypeError: can'tpickleblake2sobjects |
corona10
commented
Sep 10, 2020
I created the issue https://bugs.python.org/issue41052 when I found the issue after porting to heap type. |
serhiy-storchaka
commented
Nov 21, 2020
This is no longer needed, is not? |
corona10
commented
Nov 23, 2020
@serhiy-storchaka Yeah this pr is no needed ;) |
vstinner
commented
Nov 23, 2020
Cool. I like the fact that it's no longer needed thanks to the generic https://bugs.python.org/issue41052 fix :-D Thanks again for the generic fix! It's way better than such copy/paste fix on each type. |
https://bugs.python.org/issue41052