diff options
author | 2013-10-22 15:05:23 +0200 | |
---|---|---|
committer | 2013-10-22 15:05:23 +0200 | |
commit | 327dd732ce2b7df001b0a052e3464c85f0c85128 (patch) | |
tree | 503582cbb9364f320bc9754340c7a6a2dde23e40 /Modules/sha256module.c | |
parent | Issue #18742: Rework the internal hashlib construtor to pave the road for ABCs. (diff) | |
download | cpython-327dd732ce2b7df001b0a052e3464c85f0c85128.tar.gz cpython-327dd732ce2b7df001b0a052e3464c85f0c85128.tar.bz2 cpython-327dd732ce2b7df001b0a052e3464c85f0c85128.zip |
Issue #18742: Expose the internal hash type object for ABCs.
Diffstat (limited to 'Modules/sha256module.c')
-rw-r--r-- | Modules/sha256module.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Modules/sha256module.c b/Modules/sha256module.c index e60111ad02d..b05bfc172f5 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; + } |