summaryrefslogtreecommitdiff
path: root/python/tag.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-06-08 17:17:48 +0200
committerJulian Andres Klode <jak@debian.org>2009-06-08 17:17:48 +0200
commit1040f7f6ec9cf689d6530827348a63daad52b3ef (patch)
treee043184e4e1ee74126059881a03b38a3a845f611 /python/tag.cc
parent857774704739c39a68a1e72914a82e001e62ec93 (diff)
downloadpython-apt-1040f7f6ec9cf689d6530827348a63daad52b3ef.tar.gz
python/generic.h,tag.cc,configuration.cc: Use tp_alloc/tp_free instead of PyObject_NEW/DEL
This allows us to finally implement subclassing. Previously deletion of an instance of a subclass caused segmentation faults, this is not the case anymore.
Diffstat (limited to 'python/tag.cc')
-rw-r--r--python/tag.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/python/tag.cc b/python/tag.cc
index 5a31488c..31491c90 100644
--- a/python/tag.cc
+++ b/python/tag.cc
@@ -68,7 +68,7 @@ void TagFileFree(PyObject *Obj)
Self->Object.~pkgTagFile();
Self->Fd.~FileFd();
Py_DECREF(Self->File);
- PyObject_DEL(Obj);
+ Obj->ob_type->tp_free(Obj);
}
/*}}}*/
@@ -246,7 +246,7 @@ static PyObject *TagSecNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) {
return 0;
// Create the object..
- TagSecData *New = PyObject_NEW(TagSecData,type);
+ TagSecData *New = (TagSecData*)type->tp_alloc(type, 0);
new (&New->Object) pkgTagSection();
New->Data = new char[strlen(Data)+2];
snprintf(New->Data,strlen(Data)+2,"%s\n",Data);
@@ -286,14 +286,14 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
if (fileno == -1)
return 0;
- TagFileData *New = PyObject_NEW(TagFileData,type);
+ TagFileData *New = (TagFileData*)type->tp_alloc(type, 0);
new (&New->Fd) FileFd(fileno,false);
New->File = File;
Py_INCREF(New->File);
new (&New->Object) pkgTagFile(&New->Fd);
// Create the section
- New->Section = PyObject_NEW(TagSecData,&TagSecType);
+ New->Section = (TagSecData*)(&TagSecType)->tp_alloc(&TagSecType, 0);
new (&New->Section->Object) pkgTagSection();
New->Section->Data = 0;