Mailing List Archive

CVS: python/dist/src/Modules arraymodule.c,2.68,2.69 cmathmodule.c,2.28,2.29
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv29107

Modified Files:
arraymodule.c cmathmodule.c
Log Message:
Use the PyModule_*() API instead of manipulating the module dictionary
directly.


Index: arraymodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v
retrieving revision 2.68
retrieving revision 2.69
diff -C2 -d -r2.68 -r2.69
*** arraymodule.c 4 Mar 2002 09:38:52 -0000 2.68
--- arraymodule.c 1 Apr 2002 03:45:06 -0000 2.69
***************
*** 1732,1742 ****
initarray(void)
{
! PyObject *m, *d;

Arraytype.ob_type = &PyType_Type;
m = Py_InitModule3("array", a_methods, module_doc);
! d = PyModule_GetDict(m);
! PyDict_SetItemString(d, "ArrayType", (PyObject *)&Arraytype);
! PyDict_SetItemString(d, "array", (PyObject *)&Arraytype);
/* No need to check the error here, the caller will do that */
}
--- 1732,1744 ----
initarray(void)
{
! PyObject *m;

Arraytype.ob_type = &PyType_Type;
m = Py_InitModule3("array", a_methods, module_doc);
!
! Py_INCREF((PyObject *)&Arraytype);
! PyModule_AddObject(m, "ArrayType", (PyObject *)&Arraytype);
! Py_INCREF((PyObject *)&Arraytype);
! PyModule_AddObject(m, "array", (PyObject *)&Arraytype);
/* No need to check the error here, the caller will do that */
}

Index: cmathmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cmathmodule.c,v
retrieving revision 2.28
retrieving revision 2.29
diff -C2 -d -r2.28 -r2.29
*** cmathmodule.c 9 Mar 2002 04:58:24 -0000 2.28
--- cmathmodule.c 1 Apr 2002 03:45:06 -0000 2.29
***************
*** 395,406 ****
initcmath(void)
{
! PyObject *m, *d, *v;

m = Py_InitModule3("cmath", cmath_methods, module_doc);
! d = PyModule_GetDict(m);
! PyDict_SetItemString(d, "pi",
! v = PyFloat_FromDouble(atan(1.0) * 4.0));
! Py_DECREF(v);
! PyDict_SetItemString(d, "e", v = PyFloat_FromDouble(exp(1.0)));
! Py_DECREF(v);
}
--- 395,404 ----
initcmath(void)
{
! PyObject *m;

m = Py_InitModule3("cmath", cmath_methods, module_doc);
!
! PyModule_AddObject(m, "pi",
! PyFloat_FromDouble(atan(1.0) * 4.0));
! PyModule_AddObject(m, "e", PyFloat_FromDouble(exp(1.0)));
}