Kaydet (Commit) 1155887a authored tarafından Tim Peters's avatar Tim Peters

initgc(): Rewrote to use the PyModule_AddXYZ API; cuts code size.

üst 259272b7
...@@ -973,32 +973,29 @@ void ...@@ -973,32 +973,29 @@ void
initgc(void) initgc(void)
{ {
PyObject *m; PyObject *m;
PyObject *d;
m = Py_InitModule4("gc", m = Py_InitModule4("gc",
GcMethods, GcMethods,
gc__doc__, gc__doc__,
NULL, NULL,
PYTHON_API_VERSION); PYTHON_API_VERSION);
d = PyModule_GetDict(m);
if (garbage == NULL) { if (garbage == NULL) {
garbage = PyList_New(0); garbage = PyList_New(0);
if (garbage == NULL)
return;
} }
PyDict_SetItemString(d, "garbage", garbage); if (PyModule_AddObject(m, "garbage", garbage) < 0)
PyDict_SetItemString(d, "DEBUG_STATS", return;
PyInt_FromLong(DEBUG_STATS)); #define ADD_INT(NAME) if (PyModule_AddIntConstant(m, #NAME, NAME) < 0) return
PyDict_SetItemString(d, "DEBUG_COLLECTABLE", ADD_INT(DEBUG_STATS);
PyInt_FromLong(DEBUG_COLLECTABLE)); ADD_INT(DEBUG_COLLECTABLE);
PyDict_SetItemString(d, "DEBUG_UNCOLLECTABLE", ADD_INT(DEBUG_UNCOLLECTABLE);
PyInt_FromLong(DEBUG_UNCOLLECTABLE)); ADD_INT(DEBUG_INSTANCES);
PyDict_SetItemString(d, "DEBUG_INSTANCES", ADD_INT(DEBUG_OBJECTS);
PyInt_FromLong(DEBUG_INSTANCES)); ADD_INT(DEBUG_SAVEALL);
PyDict_SetItemString(d, "DEBUG_OBJECTS", ADD_INT(DEBUG_LEAK);
PyInt_FromLong(DEBUG_OBJECTS)); #undef ADD_INT
PyDict_SetItemString(d, "DEBUG_SAVEALL",
PyInt_FromLong(DEBUG_SAVEALL));
PyDict_SetItemString(d, "DEBUG_LEAK",
PyInt_FromLong(DEBUG_LEAK));
} }
/* for debugging */ /* for debugging */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment