summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-10-22 13:05:23 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-10-22 13:05:23 (GMT)
commit327dd732ce2b7df001b0a052e3464c85f0c85128 (patch)
tree503582cbb9364f320bc9754340c7a6a2dde23e40
parente53510726b337762d005984eeab0b266c60b779d (diff)
downloadcpython-327dd732ce2b7df001b0a052e3464c85f0c85128.zip
cpython-327dd732ce2b7df001b0a052e3464c85f0c85128.tar.gz
cpython-327dd732ce2b7df001b0a052e3464c85f0c85128.tar.bz2
Issue #18742: Expose the internal hash type object for ABCs.
-rw-r--r--Modules/_hashopenssl.c4
-rw-r--r--Modules/_sha3/sha3module.c10
-rw-r--r--Modules/md5module.c11
-rw-r--r--Modules/sha1module.c11
-rw-r--r--Modules/sha256module.c14
-rw-r--r--Modules/sha512module.c13
6 files changed, 55 insertions, 8 deletions
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index 222e5ef..423b3b3 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -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);
diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c
index 4e6352b..71127d0 100644
--- a/Modules/_sha3/sha3module.c
+++ b/Modules/_sha3/sha3module.c
@@ -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;
}
diff --git a/Modules/md5module.c b/Modules/md5module.c
index bb91b6c..5cb3d36 100644
--- a/Modules/md5module.c
+++ b/Modules/md5module.c
@@ -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;
}
diff --git a/Modules/sha1module.c b/Modules/sha1module.c
index 403194c..b44fe18 100644
--- a/Modules/sha1module.c
+++ b/Modules/sha1module.c
@@ -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;
}
diff --git a/Modules/sha256module.c b/Modules/sha256module.c
index e60111a..b05bfc1 100644
--- a/Modules/sha256module.c
+++ b/Modules/sha256module.c
@@ -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;
+
}
diff --git a/Modules/sha512module.c b/Modules/sha512module.c
index 2841eab..47c57e5 100644
--- a/Modules/sha512module.c
+++ b/Modules/sha512module.c
@@ -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