summaryrefslogtreecommitdiffstats
path: root/Include/abstract.h
diff options
context:
space:
mode:
Diffstat (limited to 'Include/abstract.h')
-rw-r--r--Include/abstract.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/Include/abstract.h b/Include/abstract.h
index eaac278..357afe1 100644
--- a/Include/abstract.h
+++ b/Include/abstract.h
@@ -694,13 +694,26 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
expression: o1|o2.
*/
- PyAPI_FUNC(Py_ssize_t) PyNumber_Index(PyObject *);
+#define PyIndex_Check(obj) \
+ ((obj)->ob_type->tp_as_number != NULL && \
+ (obj)->ob_type->tp_as_number->nb_index != NULL)
+
+ PyAPI_FUNC(PyObject *) PyNumber_Index(PyObject *o);
/*
- Returns the object converted to Py_ssize_t on success
- or -1 with an error raised on failure.
+ Returns the object converted to a Python long or int
+ or NULL with an error raised on failure.
*/
+ PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc);
+
+ /*
+ Returns the object converted to Py_ssize_t by going through
+ PyNumber_Index first. If an overflow error occurs while
+ converting the int-or-long to Py_ssize_t, then the second argument
+ is the error-type to return. If it is NULL, then the overflow error
+ is cleared and the value is clipped.
+ */
PyAPI_FUNC(PyObject *) PyNumber_Int(PyObject *o);