summaryrefslogtreecommitdiffstats
path: root/siplib/siplib.c
diff options
context:
space:
mode:
Diffstat (limited to 'siplib/siplib.c')
-rw-r--r--siplib/siplib.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/siplib/siplib.c b/siplib/siplib.c
index ebbc194..2e0a5d5 100644
--- a/siplib/siplib.c
+++ b/siplib/siplib.c
@@ -551,7 +551,7 @@ static int getSelfFromArgs(sipTypeDef *td, PyObject *args, int argnr,
sipSimpleWrapper **selfp);
static PyObject *createEnumMember(sipTypeDef *td, sipEnumMemberDef *enm);
static int compareTypedefName(const void *key, const void *el);
-static int checkPointer(void *ptr);
+static int checkPointer(void *ptr, sipSimpleWrapper *sw);
static void *cast_cpp_ptr(void *ptr, PyTypeObject *src_type,
const sipTypeDef *dst_type);
static void finalise(void);
@@ -1040,7 +1040,7 @@ static PyObject *callDtor(PyObject *self, PyObject *args)
addr = getPtrTypeDef(sw, &ctd);
- if (checkPointer(addr) < 0)
+ if (checkPointer(addr, sw) < 0)
return NULL;
if (PyObject_TypeCheck((PyObject *)sw, (PyTypeObject *)&sipWrapper_Type))
@@ -7418,7 +7418,7 @@ void *sip_api_get_cpp_ptr(sipSimpleWrapper *sw, const sipTypeDef *td)
{
void *ptr = sipGetAddress(sw);
- if (checkPointer(ptr) < 0)
+ if (checkPointer(ptr, sw) < 0)
return NULL;
if (td != NULL)
@@ -7454,12 +7454,14 @@ static void *cast_cpp_ptr(void *ptr, PyTypeObject *src_type,
/*
* Check that a pointer is non-NULL.
*/
-static int checkPointer(void *ptr)
+static int checkPointer(void *ptr, sipSimpleWrapper *sw)
{
if (ptr == NULL)
{
- PyErr_SetString(PyExc_RuntimeError,
- "underlying C/C++ object has been deleted");
+ PyErr_Format(PyExc_RuntimeError, (sipWasCreated(sw) ?
+ "wrapped C/C++ object of type %s has been deleted" :
+ "super-class __init__() of type %s was never called"),
+ Py_TYPE(sw)->tp_name);
return -1;
}
@@ -8701,7 +8703,7 @@ static int sipSimpleWrapper_init(sipSimpleWrapper *self, PyObject *args,
}
self->u.cppPtr = sipNew;
- self->flags = sipFlags;
+ self->flags = sipFlags | SIP_CREATED;
if (!sipNotInMap(self))
sipOMAddObject(&cppPyMap, self);