mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fix a regression introduced by rev. 63792: ctypes function pointers
that are COM methods must have a boolean True value.
This commit is contained in:
parent
4348a25665
commit
0ad5ae02af
3 changed files with 35 additions and 6 deletions
|
@ -3938,12 +3938,13 @@ CFuncPtr_repr(CFuncPtrObject *self)
|
|||
}
|
||||
|
||||
static int
|
||||
Pointer_nonzero(CDataObject *self)
|
||||
CFuncPtr_nonzero(CFuncPtrObject *self)
|
||||
{
|
||||
return *(void **)self->b_ptr != NULL;
|
||||
return ((*(void **)self->b_ptr != NULL)
|
||||
|| (self->index != 0));
|
||||
}
|
||||
|
||||
static PyNumberMethods Pointer_as_number = {
|
||||
static PyNumberMethods CFuncPtr_as_number = {
|
||||
0, /* nb_add */
|
||||
0, /* nb_subtract */
|
||||
0, /* nb_multiply */
|
||||
|
@ -3954,7 +3955,7 @@ static PyNumberMethods Pointer_as_number = {
|
|||
0, /* nb_negative */
|
||||
0, /* nb_positive */
|
||||
0, /* nb_absolute */
|
||||
(inquiry)Pointer_nonzero, /* nb_nonzero */
|
||||
(inquiry)CFuncPtr_nonzero, /* nb_nonzero */
|
||||
};
|
||||
|
||||
PyTypeObject CFuncPtr_Type = {
|
||||
|
@ -3968,7 +3969,7 @@ PyTypeObject CFuncPtr_Type = {
|
|||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
(reprfunc)CFuncPtr_repr, /* tp_repr */
|
||||
&Pointer_as_number, /* tp_as_number */
|
||||
&CFuncPtr_as_number, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
|
@ -5176,6 +5177,26 @@ static PyMappingMethods Pointer_as_mapping = {
|
|||
Pointer_subscript,
|
||||
};
|
||||
|
||||
static int
|
||||
Pointer_nonzero(CDataObject *self)
|
||||
{
|
||||
return (*(void **)self->b_ptr != NULL);
|
||||
}
|
||||
|
||||
static PyNumberMethods Pointer_as_number = {
|
||||
0, /* nb_add */
|
||||
0, /* nb_subtract */
|
||||
0, /* nb_multiply */
|
||||
0, /* nb_divide */
|
||||
0, /* nb_remainder */
|
||||
0, /* nb_divmod */
|
||||
0, /* nb_power */
|
||||
0, /* nb_negative */
|
||||
0, /* nb_positive */
|
||||
0, /* nb_absolute */
|
||||
(inquiry)Pointer_nonzero, /* nb_nonzero */
|
||||
};
|
||||
|
||||
PyTypeObject Pointer_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes._Pointer",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue