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

bpo-1635741: Port sha256 module to multiphase init (PEP 489) #21189

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 4 commits into from
Jul 3, 2020
Merged
Changes from 1 commit
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
Next Next commit
Port sha256 module to multi-phase init (PEP 489)
  • Loading branch information
koubaa committed Jun 28, 2020
commit 9f9e45abb9f69538b24164999d6e5fd8ec8611ef
57 changes: 29 additions & 28 deletions 57 Modules/sha256module.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,43 +681,44 @@ static struct PyMethodDef SHA_functions[] = {
{NULL, NULL} /* Sentinel */
};


/* Initialize this module. */

static struct PyModuleDef _sha256module = {
PyModuleDef_HEAD_INIT,
"_sha256",
NULL,
-1,
SHA_functions,
NULL,
NULL,
NULL,
NULL
};

PyMODINIT_FUNC
PyInit__sha256(void)
static int sha256_exec(PyObject *module)
{
PyObject *m;

Py_SET_TYPE(&SHA224type, &PyType_Type);
if (PyType_Ready(&SHA224type) < 0) {
return NULL;
return -1;
}
Py_SET_TYPE(&SHA256type, &PyType_Type);
if (PyType_Ready(&SHA256type) < 0) {
return NULL;
return -1;
}

m = PyModule_Create(&_sha256module);
if (m == NULL)
return NULL;

Py_INCREF((PyObject *)&SHA224type);
PyModule_AddObject(m, "SHA224Type", (PyObject *)&SHA224type);
PyModule_AddObject(module, "SHA224Type", (PyObject *)&SHA224type);
koubaa marked this conversation as resolved.
Show resolved Hide resolved
Py_INCREF((PyObject *)&SHA256type);
PyModule_AddObject(m, "SHA256Type", (PyObject *)&SHA256type);
return m;
PyModule_AddObject(module, "SHA256Type", (PyObject *)&SHA256type);
koubaa marked this conversation as resolved.
Show resolved Hide resolved
return 0;
}

static PyModuleDef_Slot _sha256_slots[] = {
{Py_mod_exec, sha256_exec},
{0, NULL}
};

static struct PyModuleDef _sha256module = {
koubaa marked this conversation as resolved.
Show resolved Hide resolved
PyModuleDef_HEAD_INIT,
"_sha256",
koubaa marked this conversation as resolved.
Show resolved Hide resolved
NULL,
0,
SHA_functions,
_sha256_slots,
NULL,
NULL,
NULL
};

/* Initialize this module. */
PyMODINIT_FUNC
PyInit__sha256(void)
{
return PyModuleDef_Init(&_sha256module);
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.