gh-135532: use defining_class for copying BLAKE-2 and SHA-3 objects (#135838)

This commit is contained in:
Bénédikt Tran 2025-06-24 09:58:07 +02:00 committed by GitHub
parent 34393cbdd4
commit ef4fc86afa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 38 additions and 17 deletions

View file

@ -787,17 +787,19 @@ blake2_blake2b_copy_unlocked(Blake2Object *self, Blake2Object *cpy)
/*[clinic input]
_blake2.blake2b.copy
cls: defining_class
Return a copy of the hash object.
[clinic start generated code]*/
static PyObject *
_blake2_blake2b_copy_impl(Blake2Object *self)
/*[clinic end generated code: output=622d1c56b91c50d8 input=e383c2d199fd8a2e]*/
_blake2_blake2b_copy_impl(Blake2Object *self, PyTypeObject *cls)
/*[clinic end generated code: output=5f8ea31c56c52287 input=f38f3475e9aec98d]*/
{
int rc;
Blake2Object *cpy;
if ((cpy = new_Blake2Object(Py_TYPE(self))) == NULL) {
if ((cpy = new_Blake2Object(cls)) == NULL) {
return NULL;
}