Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0dc6710

Browse filesBrowse files
encukoustratakis
authored andcommitted
_hashopenssl: Uncomment and use initialization function list
This simplifies backporting of future changes. We use this change instead of Python 3.10's: bpo-1635741: Port _hashlib to multiphase initialization (pythonGH-23358)
1 parent 72ecc6d commit 0dc6710
Copy full SHA for 0dc6710

File tree

1 file changed

+5
-25
lines changed
Filter options

1 file changed

+5
-25
lines changed

‎Modules/_hashopenssl.c

Copy file name to clipboardExpand all lines: Modules/_hashopenssl.c
+5-25Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,7 +2215,6 @@ hashlib_init_hmactype(PyObject *module)
22152215
return 0;
22162216
}
22172217

2218-
#if 0
22192218
static PyModuleDef_Slot hashlib_slots[] = {
22202219
/* OpenSSL 1.0.2 and LibreSSL */
22212220
{Py_mod_exec, hashlib_openssl_legacy_init},
@@ -2226,7 +2225,6 @@ static PyModuleDef_Slot hashlib_slots[] = {
22262225
{Py_mod_exec, hashlib_md_meth_names},
22272226
{0, NULL}
22282227
};
2229-
#endif
22302228

22312229
static struct PyModuleDef _hashlibmodule = {
22322230
PyModuleDef_HEAD_INIT,
@@ -2254,29 +2252,11 @@ PyInit__hashlib(void)
22542252
return NULL;
22552253
}
22562254

2257-
if (hashlib_openssl_legacy_init(m) < 0) {
2258-
Py_DECREF(m);
2259-
return NULL;
2260-
}
2261-
if (hashlib_init_hashtable(m) < 0) {
2262-
Py_DECREF(m);
2263-
return NULL;
2264-
}
2265-
if (hashlib_init_evptype(m) < 0) {
2266-
Py_DECREF(m);
2267-
return NULL;
2268-
}
2269-
if (hashlib_init_evpxoftype(m) < 0) {
2270-
Py_DECREF(m);
2271-
return NULL;
2272-
}
2273-
if (hashlib_init_hmactype(m) < 0) {
2274-
Py_DECREF(m);
2275-
return NULL;
2276-
}
2277-
if (hashlib_md_meth_names(m) == -1) {
2278-
Py_DECREF(m);
2279-
return NULL;
2255+
for (int i=0; hashlib_slots[i].slot; i++) {
2256+
if (((int (*)(PyObject*))hashlib_slots[i].value)(m) < 0) {
2257+
Py_DECREF(m);
2258+
return NULL;
2259+
}
22802260
}
22812261

22822262
return m;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.