comparison src/if_python3.c @ 4966:620d9b59d4ed v7.3.1228

updated for version 7.3.1228 Problem: Python: various inconsistencies and problems. Solution: StringToLine now supports both bytes() and unicode() objects. Make function names consistant. Fix memory leak fixed in StringToLine. (ZyX)
author Bram Moolenaar <bram@vim.org>
date Sun, 23 Jun 2013 13:11:18 +0200
parents 7b8991e084f9
children b6e693e1f946
comparison
equal deleted inserted replaced
4965:cc65e359c1ee 4966:620d9b59d4ed
82 /* Python 3 does not support CObjects, always use Capsules */ 82 /* Python 3 does not support CObjects, always use Capsules */
83 #define PY_USE_CAPSULE 83 #define PY_USE_CAPSULE
84 84
85 #define PyInt Py_ssize_t 85 #define PyInt Py_ssize_t
86 #define PyString_Check(obj) PyUnicode_Check(obj) 86 #define PyString_Check(obj) PyUnicode_Check(obj)
87 #define PyString_AsBytes(obj) PyUnicode_AsEncodedString(obj, (char *)ENC_OPT, CODEC_ERROR_HANDLER)
88 #define PyString_FreeBytes(obj) Py_XDECREF(bytes)
89 #define PyString_AsString(obj) PyBytes_AsString(obj)
90 #define PyString_Size(obj) PyBytes_GET_SIZE(bytes)
91 #define PyString_FromString(repr) PyUnicode_FromString(repr) 87 #define PyString_FromString(repr) PyUnicode_FromString(repr)
92 #define PyString_FromFormat PyUnicode_FromFormat 88 #define PyString_FromFormat PyUnicode_FromFormat
93 #define PyString_AsStringAndSize(obj, buffer, len) PyBytes_AsStringAndSize(obj, buffer, len)
94 #define PyInt_Check(obj) PyLong_Check(obj) 89 #define PyInt_Check(obj) PyLong_Check(obj)
95 #define PyInt_FromLong(i) PyLong_FromLong(i) 90 #define PyInt_FromLong(i) PyLong_FromLong(i)
96 #define PyInt_AsLong(obj) PyLong_AsLong(obj) 91 #define PyInt_AsLong(obj) PyLong_AsLong(obj)
97 #define Py_ssize_t_fmt "n" 92 #define Py_ssize_t_fmt "n"
98 #define Py_bytes_fmt "y" 93 #define Py_bytes_fmt "y"
355 # else 350 # else
356 static char* (*py3__PyUnicode_AsString)(PyObject *unicode); 351 static char* (*py3__PyUnicode_AsString)(PyObject *unicode);
357 # endif 352 # endif
358 static PyObject* (*py3_PyUnicode_AsEncodedString)(PyObject *unicode, const char* encoding, const char* errors); 353 static PyObject* (*py3_PyUnicode_AsEncodedString)(PyObject *unicode, const char* encoding, const char* errors);
359 static char* (*py3_PyBytes_AsString)(PyObject *bytes); 354 static char* (*py3_PyBytes_AsString)(PyObject *bytes);
360 static int (*py3_PyBytes_AsStringAndSize)(PyObject *bytes, char **buffer, int *length); 355 static int (*py3_PyBytes_AsStringAndSize)(PyObject *bytes, char **buffer, Py_ssize_t *length);
361 static PyObject* (*py3_PyBytes_FromString)(char *str); 356 static PyObject* (*py3_PyBytes_FromString)(char *str);
362 static PyObject* (*py3_PyFloat_FromDouble)(double num); 357 static PyObject* (*py3_PyFloat_FromDouble)(double num);
363 static double (*py3_PyFloat_AsDouble)(PyObject *); 358 static double (*py3_PyFloat_AsDouble)(PyObject *);
364 static PyObject* (*py3_PyObject_GenericGetAttr)(PyObject *obj, PyObject *name); 359 static PyObject* (*py3_PyObject_GenericGetAttr)(PyObject *obj, PyObject *name);
365 static PyObject* (*py3_PyType_GenericAlloc)(PyTypeObject *type, Py_ssize_t nitems); 360 static PyObject* (*py3_PyType_GenericAlloc)(PyTypeObject *type, Py_ssize_t nitems);