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 46f59eb

Browse filesBrowse files
authored
bpo-1635741: Port _hashlib to multiphase initialization (GH-23358)
Signed-off-by: Christian Heimes <christian@python.org>
1 parent c701101 commit 46f59eb
Copy full SHA for 46f59eb

File tree

2 files changed

+3
-36
lines changed
Filter options

2 files changed

+3
-36
lines changed
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Port _hashlib extension module to multiphase initialization (:pep:`489`)

‎Modules/_hashopenssl.c

Copy file name to clipboardExpand all lines: Modules/_hashopenssl.c
+2-36Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,6 @@ hashlib_init_hmactype(PyObject *module)
20782078
return 0;
20792079
}
20802080

2081-
#if 0
20822081
static PyModuleDef_Slot hashlib_slots[] = {
20832082
/* OpenSSL 1.0.2 and LibreSSL */
20842083
{Py_mod_exec, hashlib_openssl_legacy_init},
@@ -2088,15 +2087,14 @@ static PyModuleDef_Slot hashlib_slots[] = {
20882087
{Py_mod_exec, hashlib_md_meth_names},
20892088
{0, NULL}
20902089
};
2091-
#endif
20922090

20932091
static struct PyModuleDef _hashlibmodule = {
20942092
PyModuleDef_HEAD_INIT,
20952093
.m_name = "_hashlib",
20962094
.m_doc = "OpenSSL interface for hashlib module",
20972095
.m_size = sizeof(_hashlibstate),
20982096
.m_methods = EVP_functions,
2099-
.m_slots = NULL,
2097+
.m_slots = hashlib_slots,
21002098
.m_traverse = hashlib_traverse,
21012099
.m_clear = hashlib_clear,
21022100
.m_free = hashlib_free
@@ -2105,37 +2103,5 @@ static struct PyModuleDef _hashlibmodule = {
21052103
PyMODINIT_FUNC
21062104
PyInit__hashlib(void)
21072105
{
2108-
PyObject *m = PyState_FindModule(&_hashlibmodule);
2109-
if (m != NULL) {
2110-
Py_INCREF(m);
2111-
return m;
2112-
}
2113-
2114-
m = PyModule_Create(&_hashlibmodule);
2115-
if (m == NULL) {
2116-
return NULL;
2117-
}
2118-
2119-
if (hashlib_openssl_legacy_init(m) < 0) {
2120-
Py_DECREF(m);
2121-
return NULL;
2122-
}
2123-
if (hashlib_init_evptype(m) < 0) {
2124-
Py_DECREF(m);
2125-
return NULL;
2126-
}
2127-
if (hashlib_init_evpxoftype(m) < 0) {
2128-
Py_DECREF(m);
2129-
return NULL;
2130-
}
2131-
if (hashlib_init_hmactype(m) < 0) {
2132-
Py_DECREF(m);
2133-
return NULL;
2134-
}
2135-
if (hashlib_md_meth_names(m) == -1) {
2136-
Py_DECREF(m);
2137-
return NULL;
2138-
}
2139-
2140-
return m;
2106+
return PyModuleDef_Init(&_hashlibmodule);
21412107
}

0 commit comments

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