mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Better implementation of PyCObject_AsVoidPtr().
This commit is contained in:
parent
cbd1e4eb5f
commit
04f95d5238
1 changed files with 18 additions and 7 deletions
|
@ -57,13 +57,6 @@ PyCObject_FromVoidPtr(cobj, destr)
|
||||||
return (PyObject *)self;
|
return (PyObject *)self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
PyCObject_AsVoidPtr(self)
|
|
||||||
PyObject *self;
|
|
||||||
{
|
|
||||||
return ((PyCObject *)self)->cobject;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
PyCObject_dealloc(self)
|
PyCObject_dealloc(self)
|
||||||
PyCObject *self;
|
PyCObject *self;
|
||||||
|
@ -105,3 +98,21 @@ PyTypeObject PyCObject_Type = {
|
||||||
0L,0L,0L,0L,
|
0L,0L,0L,0L,
|
||||||
PyCObject_Type__doc__ /* Documentation string */
|
PyCObject_Type__doc__ /* Documentation string */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void *
|
||||||
|
PyCObject_AsVoidPtr(self)
|
||||||
|
PyObject *self;
|
||||||
|
{
|
||||||
|
if(self)
|
||||||
|
{
|
||||||
|
if(self->ob_type == &PyCObject_Type)
|
||||||
|
return ((PyCObject *)self)->cobject;
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"PyCObject_AsVoidPtr with non-C-object");
|
||||||
|
}
|
||||||
|
if(! PyErr_Occurred())
|
||||||
|
PyErr_SetString(
|
||||||
|
PyExc_TypeError,
|
||||||
|
"PyCObject_AsVoidPtr called with null pointer");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue