[Zope-Checkins] CVS: Zope3/lib/python/Zope/ContextWrapper - wrapper.c:1.12.2.13
Fred L. Drake, Jr.
fdrake@acm.org
Thu, 18 Apr 2002 10:25:08 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/ContextWrapper
In directory cvs.zope.org:/tmp/cvs-serv6710
Modified Files:
Tag: Zope-3x-branch
wrapper.c
Log Message:
wrap_dealloc(): Call the tp_free handler so we do not leak memory.
wrap_getattro(): Remove use of the temporary variable that is not needed.
WrapperType: Set the GC flag so the type gets to participate in cycle
detection & cleanup.
=== Zope3/lib/python/Zope/ContextWrapper/wrapper.c 1.12.2.12 => 1.12.2.13 ===
{
(void) wrap_clear(self);
+ self->ob_type->tp_free(self);
}
static PyObject *
wrap_getattro(PyObject *self, PyObject *name)
{
- PyObject *result;
/*
This commented-out version allows subclasses of the Wrapper type
to add new attributes. To do so and still make __class__ still
@@ -127,6 +127,8 @@
Questions.
*/
/*
+ PyObject *result;
+
char *s = PyString_AS_STRING(name);
if (s[0] == '_' && strcmp(s, "__class__") == 0) {
result = (PyObject *)(Wrapper_GetObject(self)->ob_type);
@@ -139,10 +141,9 @@
result = PyObject_GetAttr(Wrapper_GetObject(self), name);
}
}
+ return result;
*/
-
- result = PyObject_GetAttr(Wrapper_GetObject(self), name);
- return result;
+ return PyObject_GetAttr(Wrapper_GetObject(self), name);
}
static int
@@ -354,12 +355,13 @@
&wrap_as_sequence, /* tp_as_sequence */
&wrap_as_mapping, /* tp_as_mapping */
wrap_hash, /* tp_hash */
- wrap_call, /* tp_call */
+ wrap_call, /* tp_call */
wrap_str, /* tp_str */
wrap_getattro, /* tp_getattro */
wrap_setattro, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
+ | Py_TPFLAGS_HAVE_GC, /* tp_flags */
0, /* tp_doc */
wrap_traverse, /* tp_traverse */
wrap_clear, /* tp_clear */