Skip to content

Commit 972479d

Browse files
committed
fix exception type in _hashlib.HMAC.copy
1 parent c41e3d0 commit 972479d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Modules/_hashopenssl.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,8 +1575,7 @@ _hashlib_hmac_new_impl(PyObject *module, Py_buffer *key, PyObject *msg_obj,
15751575

15761576
HMAC_CTX *ctx = HMAC_CTX_new();
15771577
if (ctx == NULL) {
1578-
_setException(PyExc_ValueError, NULL);
1579-
return NULL;
1578+
return PyErr_NoMemory();
15801579
}
15811580

15821581
int ok = HMAC_Init_ex(ctx, key->buf, (int)key->len, digest, NULL);
@@ -1670,14 +1669,14 @@ _hashlib_HMAC_copy_impl(HMACobject *self)
16701669

16711670
HMAC_CTX *ctx = HMAC_CTX_new();
16721671
if (ctx == NULL) {
1673-
return _setException(PyExc_ValueError, NULL);
1672+
return PyErr_NoMemory();
16741673
}
16751674
if (!locked_HMAC_CTX_copy(ctx, self)) {
16761675
HMAC_CTX_free(ctx);
16771676
return _setException(PyExc_ValueError, NULL);
16781677
}
16791678

1680-
retval = (HMACobject *)PyObject_New(HMACobject, Py_TYPE(self));
1679+
retval = PyObject_New(HMACobject, Py_TYPE(self));
16811680
if (retval == NULL) {
16821681
HMAC_CTX_free(ctx);
16831682
return NULL;

0 commit comments

Comments
 (0)