summaryrefslogtreecommitdiff
path: root/Modules/gcmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r--Modules/gcmodule.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 10a4ed7f6a..d8893d1b16 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -65,9 +65,6 @@ static PyObject *garbage = NULL;
/* Python string to use if unhandled exception occurs */
static PyObject *gc_str = NULL;
-/* Python string used to look for __del__ attribute. */
-static PyObject *delstr = NULL;
-
/* This is the number of objects who survived the last full collection. It
approximates the number of long lived objects tracked by the GC.
@@ -680,8 +677,8 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old)
static void
debug_cycle(char *msg, PyObject *op)
{
- PySys_WriteStderr("gc: %.100s <%.100s %p>\n",
- msg, Py_TYPE(op)->tp_name, op);
+ PySys_FormatStderr("gc: %s <%s %p>\n",
+ msg, Py_TYPE(op)->tp_name, op);
}
/* Handle uncollectable garbage (cycles with finalizers, and stuff reachable
@@ -762,6 +759,9 @@ clear_freelists(void)
(void)PyTuple_ClearFreeList();
(void)PyUnicode_ClearFreeList();
(void)PyFloat_ClearFreeList();
+ (void)PyList_ClearFreeList();
+ (void)PyDict_ClearFreeList();
+ (void)PySet_ClearFreeList();
}
static double
@@ -769,7 +769,9 @@ get_time(void)
{
double result = 0;
if (tmod != NULL) {
- PyObject *f = PyObject_CallMethod(tmod, "time", NULL);
+ _Py_IDENTIFIER(time);
+
+ PyObject *f = _PyObject_CallMethodId(tmod, &PyId_time, NULL);
if (f == NULL) {
PyErr_Clear();
}
@@ -797,12 +799,6 @@ collect(int generation)
PyGC_Head *gc;
double t1 = 0.0;
- if (delstr == NULL) {
- delstr = PyUnicode_InternFromString("__del__");
- if (delstr == NULL)
- Py_FatalError("gc couldn't allocate \"__del__\"");
- }
-
if (debug & DEBUG_STATS) {
PySys_WriteStderr("gc: collecting generation %d...\n",
generation);