| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -371,6 +371,16 @@ def test_get_builtin_constructor(self): | |||
| 371 | 371 | self.assertIs(constructor, _md5.md5) | |
| 372 | 372 | self.assertEqual(sorted(builtin_constructor_cache), ['MD5', 'md5']) | |
| 373 | 373 | ||
| 374 | + def test_copy(self): | ||
| 375 | + for cons in self.hash_constructors: | ||
| 376 | + h1 = cons(os.urandom(16), usedforsecurity=False) | ||
| 377 | + h2 = h1.copy() | ||
| 378 | + self.assertIs(type(h1), type(h2)) | ||
| 379 | + self.assertEqual(h1.name, h2.name) | ||
| 380 | + size = (16,) if h1.name in self.shakes else () | ||
| 381 | + self.assertEqual(h1.digest(*size), h2.digest(*size)) | ||
| 382 | + self.assertEqual(h1.hexdigest(*size), h2.hexdigest(*size)) | ||
| 383 | + | ||
| 374 | 384 | def test_hexdigest(self): | |
| 375 | 385 | for cons in self.hash_constructors: | |
| 376 | 386 | h = cons(usedforsecurity=False) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -787,17 +787,19 @@ blake2_blake2b_copy_unlocked(Blake2Object *self, Blake2Object *cpy) | |||
| 787 | 787 | /*[clinic input] | |
| 788 | 788 | _blake2.blake2b.copy | |
| 789 | 789 | ||
| 790 | + cls: defining_class | ||
| 791 | + | ||
| 790 | 792 | Return a copy of the hash object. | |
| 791 | 793 | [clinic start generated code]*/ | |
| 792 | 794 | ||
| 793 | 795 | static PyObject * | |
| 794 | - _blake2_blake2b_copy_impl(Blake2Object *self) | ||
| 795 | - /*[clinic end generated code: output=622d1c56b91c50d8 input=e383c2d199fd8a2e]*/ | ||
| 796 | + _blake2_blake2b_copy_impl(Blake2Object *self, PyTypeObject *cls) | ||
| 797 | + /*[clinic end generated code: output=5f8ea31c56c52287 input=f38f3475e9aec98d]*/ | ||
| 796 | 798 | { | |
| 797 | 799 | int rc; | |
| 798 | 800 | Blake2Object *cpy; | |
| 799 | 801 | ||
| 800 | - if ((cpy = new_Blake2Object(Py_TYPE(self))) == NULL) { | ||
| 802 | + if ((cpy = new_Blake2Object(cls)) == NULL) { | ||
| 801 | 803 | return NULL; | |
| 802 | 804 | } | |
| 803 | 805 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -239,16 +239,17 @@ SHA3_traverse(PyObject *self, visitproc visit, void *arg) | |||
| 239 | 239 | /*[clinic input] | |
| 240 | 240 | _sha3.sha3_224.copy | |
| 241 | 241 | ||
| 242 | + cls: defining_class | ||
| 243 | + | ||
| 242 | 244 | Return a copy of the hash object. | |
| 243 | 245 | [clinic start generated code]*/ | |
| 244 | 246 | ||
| 245 | 247 | static PyObject * | |
| 246 | - _sha3_sha3_224_copy_impl(SHA3object *self) | ||
| 247 | - /*[clinic end generated code: output=6c537411ecdcda4c input=93a44aaebea51ba8]*/ | ||
| 248 | + _sha3_sha3_224_copy_impl(SHA3object *self, PyTypeObject *cls) | ||
| 249 | + /*[clinic end generated code: output=13958b44c244013e input=7134b4dc0a2fbcac]*/ | ||
| 248 | 250 | { | |
| 249 | 251 | SHA3object *newobj; | |
| 250 | - | ||
| 251 | - if ((newobj = newSHA3object(Py_TYPE(self))) == NULL) { | ||
| 252 | + if ((newobj = newSHA3object(cls)) == NULL) { | ||
| 252 | 253 | return NULL; | |
| 253 | 254 | } | |
| 254 | 255 | HASHLIB_ACQUIRE_LOCK(self); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments