summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c15
-rw-r--r--Objects/exceptions.c6
2 files changed, 21 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
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index bfc818f..bcb1fd5 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -342,6 +342,12 @@ PyException_SetContext(PyObject *self, PyObject *context)
Py_XSETREF(((PyBaseExceptionObject *)self)->context, context);
}
+#undef PyExceptionClass_Name
+char *
+PyExceptionClass_Name(PyObject *ob)
+{
+ return ((PyTypeObject*)ob)->tp_name;
+}
static struct PyMemberDef BaseException_members[] = {
{"__suppress_context__", T_BOOL,