diff options
Diffstat (limited to 'Include')
-rw-r--r-- | Include/abstract.h | 19 | ||||
-rw-r--r-- | Include/code.h | 3 | ||||
-rw-r--r-- | Include/import.h | 2 | ||||
-rw-r--r-- | Include/object.h | 2 | ||||
-rw-r--r-- | Include/pyerrors.h | 1 | ||||
-rw-r--r-- | Include/unicodeobject.h | 24 |
6 files changed, 46 insertions, 5 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); diff --git a/Include/code.h b/Include/code.h index 432ec8e..3de77b6 100644 --- a/Include/code.h +++ b/Include/code.h @@ -88,6 +88,9 @@ typedef struct _addr_pair { PyAPI_FUNC(int) PyCode_CheckLineNumber(PyCodeObject* co, int lasti, PyAddrPair *bounds); +PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts, + PyObject *names, PyObject *lineno_obj); + #ifdef __cplusplus } #endif diff --git a/Include/import.h b/Include/import.h index a4e5c0e..414e059 100644 --- a/Include/import.h +++ b/Include/import.h @@ -22,7 +22,7 @@ PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(char *name, PyAPI_FUNC(PyObject *) PyImport_ImportModuleEx( char *name, PyObject *globals, PyObject *locals, PyObject *fromlist); #define PyImport_ImportModuleEx(n, g, l, f) \ - PyImport_ImportModuleLevel(n, g, l, f, -1); + PyImport_ImportModuleLevel(n, g, l, f, -1) PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name); PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m); diff --git a/Include/object.h b/Include/object.h index b69ee31..1f1aeaa 100644 --- a/Include/object.h +++ b/Include/object.h @@ -190,7 +190,7 @@ typedef struct { binaryfunc nb_inplace_floor_divide; binaryfunc nb_inplace_true_divide; - lenfunc nb_index; + unaryfunc nb_index; } PyNumberMethods; typedef struct { diff --git a/Include/pyerrors.h b/Include/pyerrors.h index 5df334b..67f1909 100644 --- a/Include/pyerrors.h +++ b/Include/pyerrors.h @@ -166,6 +166,7 @@ PyAPI_DATA(PyObject *) PyExc_SyntaxWarning; PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; PyAPI_DATA(PyObject *) PyExc_FutureWarning; PyAPI_DATA(PyObject *) PyExc_ImportWarning; +PyAPI_DATA(PyObject *) PyExc_UnicodeWarning; /* Convenience functions */ diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index c7e07a8..33aa185 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -189,6 +189,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE; # define PyUnicode_RSplit PyUnicodeUCS2_RSplit # define PyUnicode_Replace PyUnicodeUCS2_Replace # define PyUnicode_Resize PyUnicodeUCS2_Resize +# define PyUnicode_RichCompare PyUnicodeUCS2_RichCompare # define PyUnicode_SetDefaultEncoding PyUnicodeUCS2_SetDefaultEncoding # define PyUnicode_Split PyUnicodeUCS2_Split # define PyUnicode_Splitlines PyUnicodeUCS2_Splitlines @@ -266,6 +267,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE; # define PyUnicode_RSplit PyUnicodeUCS4_RSplit # define PyUnicode_Replace PyUnicodeUCS4_Replace # define PyUnicode_Resize PyUnicodeUCS4_Resize +# define PyUnicode_RichCompare PyUnicodeUCS4_RichCompare # define PyUnicode_SetDefaultEncoding PyUnicodeUCS4_SetDefaultEncoding # define PyUnicode_Split PyUnicodeUCS4_Split # define PyUnicode_Splitlines PyUnicodeUCS4_Splitlines @@ -1139,6 +1141,28 @@ PyAPI_FUNC(int) PyUnicode_Compare( PyObject *right /* Right string */ ); +/* Rich compare two strings and return one of the following: + + - NULL in case an exception was raised + - Py_True or Py_False for successfuly comparisons + - Py_NotImplemented in case the type combination is unknown + + Note that Py_EQ and Py_NE comparisons can cause a UnicodeWarning in + case the conversion of the arguments to Unicode fails with a + UnicodeDecodeError. + + Possible values for op: + + Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE + +*/ + +PyAPI_FUNC(PyObject *) PyUnicode_RichCompare( + PyObject *left, /* Left string */ + PyObject *right, /* Right string */ + int op /* Operation: Py_EQ, Py_NE, Py_GT, etc. */ + ); + /* Apply a argument tuple or dictionary to a format string and return the resulting Unicode string. */ |