summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/list/listsupport.py
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2000-01-13 16:23:39 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2000-01-13 16:23:39 (GMT)
commit3d6163ad2d2ad255f19fb9a2c643c602b3155728 (patch)
treea500dc9da6e2ca2d5f2af7457de29a5401450be0 /Mac/Modules/list/listsupport.py
parent8242c9e4c44e28696808950e061137d7cc6dd407 (diff)
downloadcpython-3d6163ad2d2ad255f19fb9a2c643c602b3155728.zip
cpython-3d6163ad2d2ad255f19fb9a2c643c602b3155728.tar.gz
cpython-3d6163ad2d2ad255f19fb9a2c643c602b3155728.tar.bz2
List objects obtained through as_List(resource) are not auto-disposed upon
Python object freeing.
Diffstat (limited to 'Mac/Modules/list/listsupport.py')
-rw-r--r--Mac/Modules/list/listsupport.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/Mac/Modules/list/listsupport.py b/Mac/Modules/list/listsupport.py
index 4fd7d7e..eca08cb 100644
--- a/Mac/Modules/list/listsupport.py
+++ b/Mac/Modules/list/listsupport.py
@@ -83,13 +83,23 @@ ListObj_setattr(self, name, value)
class MyObjectDefinition(GlobalObjectDefinition):
+
+ def outputStructMembers(self):
+ ObjectDefinition.outputStructMembers(self)
+ Output("int ob_must_be_disposed;")
+
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
PyErr_SetString(List_Error,"Cannot create null List");
return NULL;
}""")
+
+ def outputInitStructMembers(self):
+ ObjectDefinition.outputInitStructMembers(self)
+ Output("it->ob_must_be_disposed = 1;")
+
def outputFreeIt(self, itselfname):
- Output("LDispose(%s);", itselfname)
+ Output("if (self->ob_must_be_disposed && %s) LDispose(%s);", itselfname, itselfname)
def outputGetattrHook(self):
Output(getattrHookCode)
@@ -114,7 +124,18 @@ methods = []
execfile(INPUTFILE)
# Function to convert any handle to a list and vv.
-f = Function(ListHandle, 'as_List', (Handle, 'h', InMode))
+##f = Function(ListHandle, 'as_List', (Handle, 'h', InMode))
+as_List_body = """
+Handle h;
+ListObject *l;
+if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &h))
+ return NULL;
+l = (ListObject *)ListObj_New(as_List(h));
+l->ob_must_be_disposed = 0;
+return Py_BuildValue("O", l);
+"""
+f = ManualGenerator("as_List", as_List_body)
+f.docstring = lambda: "(Resource)->List.\nReturns List object (which is not auto-freed!)"
functions.append(f)
f = Method(Handle, 'as_Resource', (ListHandle, 'lh', InMode))