Skip to content

gh-134531: fix _hashlib clinic directive post GH-134626 #135249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Modules/_hashopenssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static PyModuleDef _hashlibmodule;

typedef struct {
PyTypeObject *HASH_type; // based on EVP_MD
PyTypeObject *HMACtype;
PyTypeObject *HMAC_type;
#ifdef PY_OPENSSL_HAS_SHAKE
PyTypeObject *HASHXOF_type; // based on EVP_MD
#endif
Expand Down Expand Up @@ -300,11 +300,11 @@ typedef struct {
#include "clinic/_hashopenssl.c.h"
/*[clinic input]
module _hashlib
class _hashlib.HASH "HASHobject *" "((_hashlibstate *)PyModule_GetState(module))->EVPtype"
class _hashlib.HASHXOF "HASHobject *" "((_hashlibstate *)PyModule_GetState(module))->EVPXOFtype"
class _hashlib.HMAC "HMACobject *" "((_hashlibstate *)PyModule_GetState(module))->HMACtype"
class _hashlib.HASH "HASHobject *" "((_hashlibstate *)PyModule_GetState(module))->HASH_type"
class _hashlib.HASHXOF "HASHobject *" "((_hashlibstate *)PyModule_GetState(module))->HASHXOF_type"
class _hashlib.HMAC "HMACobject *" "((_hashlibstate *)PyModule_GetState(module))->HMAC_type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=4f6b8873ed13d1ff]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=eb805ce4b90b1b31]*/


/* LCOV_EXCL_START */
Expand Down Expand Up @@ -1643,7 +1643,7 @@ _hashlib_hmac_new_impl(PyObject *module, Py_buffer *key, PyObject *msg_obj,
}

_hashlibstate *state = get_hashlib_state(module);
self = PyObject_New(HMACobject, state->HMACtype);
self = PyObject_New(HMACobject, state->HMAC_type);
if (self == NULL) {
goto error;
}
Expand Down Expand Up @@ -2204,7 +2204,7 @@ hashlib_traverse(PyObject *m, visitproc visit, void *arg)
{
_hashlibstate *state = get_hashlib_state(m);
Py_VISIT(state->HASH_type);
Py_VISIT(state->HMACtype);
Py_VISIT(state->HMAC_type);
#ifdef PY_OPENSSL_HAS_SHAKE
Py_VISIT(state->HASHXOF_type);
#endif
Expand All @@ -2218,7 +2218,7 @@ hashlib_clear(PyObject *m)
{
_hashlibstate *state = get_hashlib_state(m);
Py_CLEAR(state->HASH_type);
Py_CLEAR(state->HMACtype);
Py_CLEAR(state->HMAC_type);
#ifdef PY_OPENSSL_HAS_SHAKE
Py_CLEAR(state->HASHXOF_type);
#endif
Expand Down Expand Up @@ -2296,11 +2296,11 @@ hashlib_init_hmactype(PyObject *module)
{
_hashlibstate *state = get_hashlib_state(module);

state->HMACtype = (PyTypeObject *)PyType_FromSpec(&HMACtype_spec);
if (state->HMACtype == NULL) {
state->HMAC_type = (PyTypeObject *)PyType_FromSpec(&HMACtype_spec);
if (state->HMAC_type == NULL) {
return -1;
}
if (PyModule_AddType(module, state->HMACtype) < 0) {
if (PyModule_AddType(module, state->HMAC_type) < 0) {
return -1;
}
return 0;
Expand Down
Loading