[Patch #476612] Add attributes from PEP247 to the md5 and sha modules

This commit is contained in:
Andrew M. Kuchling 2001-11-02 21:41:00 +00:00
parent a73f78b6ec
commit 75fec2c8ed
2 changed files with 11 additions and 4 deletions

View file

@ -161,6 +161,10 @@ static PyMethodDef md5_methods[] = {
static PyObject *
md5_getattr(md5object *self, char *name)
{
if (strcmp(name, "digest_size") == 0) {
return PyInt_FromLong(16);
}
return Py_FindMethod(md5_methods, (PyObject *)self, name);
}
@ -264,11 +268,13 @@ static PyMethodDef md5_functions[] = {
DL_EXPORT(void)
initmd5(void)
{
PyObject *m, *d;
PyObject *m, *d, *i;
MD5type.ob_type = &PyType_Type;
m = Py_InitModule3("md5", md5_functions, module_doc);
d = PyModule_GetDict(m);
PyDict_SetItemString(d, "MD5Type", (PyObject *)&MD5type);
if ( (i = PyInt_FromLong(16)) != NULL)
PyDict_SetItemString(d, "digest_size", i);
/* No need to check the error here, the caller will do that */
}