2012-10-14 08:47:30 +04:00
|
|
|
/*
|
2016-11-07 15:33:46 +03:00
|
|
|
Python3 definition file to consistently map the code to Python 2 or
|
2012-10-14 08:47:30 +04:00
|
|
|
Python 3.
|
|
|
|
|
|
|
|
PyInt and PyLong were merged into PyLong in Python 3, so all PyInt functions
|
|
|
|
are mapped to PyLong.
|
|
|
|
|
|
|
|
PyString, on the other hand, was split into PyBytes and PyUnicode. We map
|
|
|
|
both back onto PyString, so use PyBytes or PyUnicode where appropriate. The
|
|
|
|
only exception to this is _imagingft.c, where PyUnicode is left alone.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if PY_VERSION_HEX >= 0x03000000
|
2013-01-11 15:47:32 +04:00
|
|
|
#define PY_ARG_BYTES_LENGTH "y#"
|
2012-10-14 20:38:06 +04:00
|
|
|
|
2012-10-14 08:47:30 +04:00
|
|
|
/* Map PyInt -> PyLong */
|
|
|
|
#define PyInt_AsLong PyLong_AsLong
|
|
|
|
#define PyInt_Check PyLong_Check
|
|
|
|
#define PyInt_FromLong PyLong_FromLong
|
|
|
|
#define PyInt_AS_LONG PyLong_AS_LONG
|
2013-03-07 01:55:24 +04:00
|
|
|
#define PyInt_FromSsize_t PyLong_FromSsize_t
|
2016-05-30 00:36:40 +03:00
|
|
|
#define PyInt_AsSsize_t PyLong_AsSsize_t
|
2012-10-14 08:47:30 +04:00
|
|
|
|
2012-10-14 20:38:06 +04:00
|
|
|
#else /* PY_VERSION_HEX < 0x03000000 */
|
2013-01-11 15:47:32 +04:00
|
|
|
#define PY_ARG_BYTES_LENGTH "s#"
|
2012-10-14 08:47:30 +04:00
|
|
|
|
|
|
|
#if !defined(KEEP_PY_UNICODE)
|
|
|
|
/* Map PyUnicode -> PyString */
|
|
|
|
#undef PyUnicode_AsString
|
|
|
|
#undef PyUnicode_AS_STRING
|
|
|
|
#undef PyUnicode_Check
|
|
|
|
#undef PyUnicode_FromStringAndSize
|
|
|
|
#undef PyUnicode_FromString
|
|
|
|
#undef PyUnicode_FromFormat
|
2013-01-10 23:07:28 +04:00
|
|
|
#undef PyUnicode_DecodeFSDefault
|
2012-10-14 08:47:30 +04:00
|
|
|
|
|
|
|
#define PyUnicode_AsString PyString_AsString
|
|
|
|
#define PyUnicode_AS_STRING PyString_AS_STRING
|
|
|
|
#define PyUnicode_Check PyString_Check
|
|
|
|
#define PyUnicode_FromStringAndSize PyString_FromStringAndSize
|
|
|
|
#define PyUnicode_FromString PyString_FromString
|
|
|
|
#define PyUnicode_FromFormat PyString_FromFormat
|
2013-01-10 23:07:28 +04:00
|
|
|
#define PyUnicode_DecodeFSDefault PyString_FromString
|
2012-10-14 08:47:30 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Map PyBytes -> PyString */
|
2013-03-14 06:34:43 +04:00
|
|
|
#define PyBytesObject PyStringObject
|
2012-10-14 08:47:30 +04:00
|
|
|
#define PyBytes_AsString PyString_AsString
|
|
|
|
#define PyBytes_AS_STRING PyString_AS_STRING
|
|
|
|
#define PyBytes_Check PyString_Check
|
2013-03-14 06:34:43 +04:00
|
|
|
#define PyBytes_AsStringAndSize PyString_AsStringAndSize
|
2012-10-14 08:47:30 +04:00
|
|
|
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
|
|
|
|
#define PyBytes_FromString PyString_FromString
|
|
|
|
#define _PyBytes_Resize _PyString_Resize
|
|
|
|
|
|
|
|
#endif /* PY_VERSION_HEX < 0x03000000 */
|