From 7a565f0b9bc81b1811e31292bd501417cfab28ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Mon, 27 Jan 2003 11:39:04 +0000 Subject: Fix reference counting of iconvcodec_Type. Fixes #670715. Remove GC code; the base type does not need GC. --- Modules/_iconv_codec.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Modules/_iconv_codec.c b/Modules/_iconv_codec.c index 8e84eec..ccf63be 100644 --- a/Modules/_iconv_codec.c +++ b/Modules/_iconv_codec.c @@ -533,8 +533,6 @@ errorexit: static void iconvcodec_dealloc(iconvcodecObject *self) { - _PyObject_GC_UNTRACK(self); - if (self->enchdl != (iconv_t)-1) iconv_close(self->enchdl); if (self->dechdl != (iconv_t)-1) @@ -542,7 +540,7 @@ iconvcodec_dealloc(iconvcodecObject *self) if (self->encoding != NULL) PyMem_Free(self->encoding); - PyObject_GC_Del(self); + self->ob_type->tp_free((PyObject *)self); } static PyObject * @@ -573,8 +571,7 @@ statichere PyTypeObject iconvcodec_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HAVE_GC, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ iconvcodec_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ @@ -593,7 +590,7 @@ statichere PyTypeObject iconvcodec_Type = { 0, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ iconvcodec_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ + PyObject_Del, /* tp_free */ }; static struct PyMethodDef _iconv_codec_methods[] = { @@ -608,6 +605,7 @@ init_iconv_codec(void) m = Py_InitModule("_iconv_codec", _iconv_codec_methods); PyModule_AddStringConstant(m, "__version__", (char*)__version__); + Py_INCREF(&iconvcodec_Type); PyModule_AddObject(m, "iconvcodec", (PyObject *)(&iconvcodec_Type)); PyModule_AddStringConstant(m, "internal_encoding", UNICODE_ENCODING); -- cgit v0.12