summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 93eda62..e2700e3 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1244,6 +1244,14 @@ PyNumber_Absolute(PyObject *o)
return type_error("bad operand type for abs(): '%.200s'", o);
}
+#undef PyIndex_Check
+int
+PyIndex_Check(PyObject *obj)
+{
+ return obj->ob_type->tp_as_number != NULL &&
+ obj->ob_type->tp_as_number->nb_index != NULL;
+}
+
/* Return a Python int from the object item.
Raise TypeError if the result is not an int
or if the object cannot be interpreted as an index.
@@ -2535,6 +2543,13 @@ PyObject_GetIter(PyObject *o)
}
}
+#undef PyIter_Check
+int PyIter_Check(PyObject *obj)
+{
+ return obj->ob_type->tp_iternext != NULL &&
+ obj->ob_type->tp_iternext != &_PyObject_NextNotImplemented;
+}
+
/* Return next item.
* If an error occurs, return NULL. PyErr_Occurred() will be true.
* If the iteration terminates normally, return NULL and clear the