Issue #18742: Expose the internal hash type object for ABCs.

This commit is contained in:
Christian Heimes 2013-10-22 15:05:23 +02:00
parent e53510726b
commit 327dd732ce
6 changed files with 55 additions and 8 deletions

View File

@ -872,10 +872,8 @@ PyInit__hashlib(void)
return NULL;
}
#if HASH_OBJ_CONSTRUCTOR
Py_INCREF(&EVPtype);
Py_INCREF((PyObject *)&EVPtype);
PyModule_AddObject(m, "HASH", (PyObject *)&EVPtype);
#endif
/* these constants are used by the convenience constructors */
INIT_CONSTRUCTOR_CONSTANTS(md5);

View File

@ -576,10 +576,18 @@ static struct PyModuleDef _SHA3module = {
PyMODINIT_FUNC
PyInit__sha3(void)
{
PyObject *m;
Py_TYPE(&SHA3type) = &PyType_Type;
if (PyType_Ready(&SHA3type) < 0) {
return NULL;
}
return PyModule_Create(&_SHA3module);
m = PyModule_Create(&_SHA3module);
if (m == NULL)
return NULL;
Py_INCREF((PyObject *)&SHA3type);
PyModule_AddObject(m, "SHA3Type", (PyObject *)&SHA3type);
return m;
}

View File

@ -572,8 +572,17 @@ static struct PyModuleDef _md5module = {
PyMODINIT_FUNC
PyInit__md5(void)
{
PyObject *m;
Py_TYPE(&MD5type) = &PyType_Type;
if (PyType_Ready(&MD5type) < 0)
return NULL;
return PyModule_Create(&_md5module);
m = PyModule_Create(&_md5module);
if (m == NULL)
return NULL;
Py_INCREF((PyObject *)&MD5type);
PyModule_AddObject(m, "MD5Type", (PyObject *)&MD5type);
return m;
}

View File

@ -544,8 +544,17 @@ static struct PyModuleDef _sha1module = {
PyMODINIT_FUNC
PyInit__sha1(void)
{
PyObject *m;
Py_TYPE(&SHA1type) = &PyType_Type;
if (PyType_Ready(&SHA1type) < 0)
return NULL;
return PyModule_Create(&_sha1module);
m = PyModule_Create(&_sha1module);
if (m == NULL)
return NULL;
Py_INCREF((PyObject *)&SHA1type);
PyModule_AddObject(m, "SHA1Type", (PyObject *)&SHA1type);
return m;
}

View File

@ -706,11 +706,23 @@ static struct PyModuleDef _sha256module = {
PyMODINIT_FUNC
PyInit__sha256(void)
{
PyObject *m;
Py_TYPE(&SHA224type) = &PyType_Type;
if (PyType_Ready(&SHA224type) < 0)
return NULL;
Py_TYPE(&SHA256type) = &PyType_Type;
if (PyType_Ready(&SHA256type) < 0)
return NULL;
return PyModule_Create(&_sha256module);
m = PyModule_Create(&_sha256module);
if (m == NULL)
return NULL;
Py_INCREF((PyObject *)&SHA224type);
PyModule_AddObject(m, "SHA224Type", (PyObject *)&SHA224type);
Py_INCREF((PyObject *)&SHA256type);
PyModule_AddObject(m, "SHA256Type", (PyObject *)&SHA256type);
return m;
}

View File

@ -772,13 +772,24 @@ static struct PyModuleDef _sha512module = {
PyMODINIT_FUNC
PyInit__sha512(void)
{
PyObject *m;
Py_TYPE(&SHA384type) = &PyType_Type;
if (PyType_Ready(&SHA384type) < 0)
return NULL;
Py_TYPE(&SHA512type) = &PyType_Type;
if (PyType_Ready(&SHA512type) < 0)
return NULL;
return PyModule_Create(&_sha512module);
m = PyModule_Create(&_sha512module);
if (m == NULL)
return NULL;
Py_INCREF((PyObject *)&SHA384type);
PyModule_AddObject(m, "SHA384Type", (PyObject *)&SHA384type);
Py_INCREF((PyObject *)&SHA512type);
PyModule_AddObject(m, "SHA512Type", (PyObject *)&SHA512type);
return m;
}
#endif