summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 7ef3ea1df0..11a725dc97 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -3858,12 +3858,16 @@ CFuncPtr_repr(CFuncPtrObject *self)
}
static int
-Pointer_bool(CDataObject *self)
+CFuncPtr_bool(CFuncPtrObject *self)
{
- return *(void **)self->b_ptr != NULL;
+ return ((*(void **)self->b_ptr != NULL)
+#ifdef MS_WIN32
+ || (self->index != 0)
+#endif
+ );
}
-static PyNumberMethods Pointer_as_number = {
+static PyNumberMethods CFuncPtr_as_number = {
0, /* nb_add */
0, /* nb_subtract */
0, /* nb_multiply */
@@ -3873,7 +3877,7 @@ static PyNumberMethods Pointer_as_number = {
0, /* nb_negative */
0, /* nb_positive */
0, /* nb_absolute */
- (inquiry)Pointer_bool, /* nb_bool */
+ (inquiry)CFuncPtr_bool, /* nb_bool */
};
PyTypeObject CFuncPtr_Type = {
@@ -3887,7 +3891,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 */
@@ -4960,6 +4964,25 @@ static PyMappingMethods Pointer_as_mapping = {
Pointer_subscript,
};
+static int
+Pointer_bool(CDataObject *self)
+{
+ return (*(void **)self->b_ptr != NULL);
+}
+
+static PyNumberMethods Pointer_as_number = {
+ 0, /* nb_add */
+ 0, /* nb_subtract */
+ 0, /* nb_multiply */
+ 0, /* nb_remainder */
+ 0, /* nb_divmod */
+ 0, /* nb_power */
+ 0, /* nb_negative */
+ 0, /* nb_positive */
+ 0, /* nb_absolute */
+ (inquiry)Pointer_bool, /* nb_bool */
+};
+
PyTypeObject Pointer_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes._Pointer",