Created
December 28, 2013 13:07
-
-
Save msmhrt/8159324 to your computer and use it in GitHub Desktop.
patch to support Python 3.0 on Vim 7.4.131
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff -r 2f856c7c1d43 src/if_python3.c | |
| --- a/src/if_python3.c Sun Dec 15 10:02:33 2013 +0100 | |
| +++ b/src/if_python3.c Sat Dec 28 14:57:26 2013 +0900 | |
| @@ -79,8 +79,9 @@ | |
| # define CODEC_ERROR_HANDLER NULL | |
| #endif | |
| -/* Python 3 does not support CObjects, always use Capsules */ | |
| -#define PY_USE_CAPSULE | |
| +#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x030100b1 | |
| +# define PY_USE_CAPSULE | |
| +#endif | |
| #define PyInt Py_ssize_t | |
| #ifndef PyString_Check | |
| @@ -195,7 +196,9 @@ | |
| # define _Py_NoneStruct (*py3__Py_NoneStruct) | |
| # define _Py_FalseStruct (*py3__Py_FalseStruct) | |
| # define _Py_TrueStruct (*py3__Py_TrueStruct) | |
| -# define _PyObject_NextNotImplemented (*py3__PyObject_NextNotImplemented) | |
| +# if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x030100a1 | |
| +# define _PyObject_NextNotImplemented (*py3__PyObject_NextNotImplemented) | |
| +# endif | |
| # define PyModule_AddObject py3_PyModule_AddObject | |
| # define PyImport_AppendInittab py3_PyImport_AppendInittab | |
| # define PyImport_AddModule py3_PyImport_AddModule | |
| @@ -259,8 +262,13 @@ | |
| # undef PyUnicode_Decode | |
| # define PyUnicode_Decode py3_PyUnicode_Decode | |
| # define PyType_IsSubtype py3_PyType_IsSubtype | |
| -# define PyCapsule_New py3_PyCapsule_New | |
| -# define PyCapsule_GetPointer py3_PyCapsule_GetPointer | |
| +# ifdef PY_USE_CAPSULE | |
| +# define PyCapsule_New py3_PyCapsule_New | |
| +# define PyCapsule_GetPointer py3_PyCapsule_GetPointer | |
| +# else | |
| +# define PyCObject_FromVoidPtr py3_PyCObject_FromVoidPtr | |
| +# define PyCObject_AsVoidPtr py3_PyCObject_AsVoidPtr | |
| +# endif | |
| # if defined(Py_DEBUG) && !defined(Py_DEBUG_NO_PYMALLOC) | |
| # undef PyObject_NEW | |
| @@ -353,7 +361,9 @@ | |
| static PyObject* (*py3_PyErr_Format)(PyObject *, const char *, ...); | |
| static void (*py3_PyErr_PrintEx)(int); | |
| static PyObject*(*py3__PyObject_Init)(PyObject *, PyTypeObject *); | |
| +# if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x030100a1 | |
| static iternextfunc py3__PyObject_NextNotImplemented; | |
| +# endif | |
| static PyObject* py3__Py_NoneStruct; | |
| static PyObject* py3__Py_FalseStruct; | |
| static PyObject* py3__Py_TrueStruct; | |
| @@ -380,8 +390,13 @@ | |
| static int (*py3_PyNumber_Check)(PyObject *); | |
| static PyObject* (*py3_PyNumber_Long)(PyObject *); | |
| static PyObject* (*py3_PyErr_NewException)(char *name, PyObject *base, PyObject *dict); | |
| +# ifdef PY_USE_CAPSULE | |
| static PyObject* (*py3_PyCapsule_New)(void *, char *, PyCapsule_Destructor); | |
| static void* (*py3_PyCapsule_GetPointer)(PyObject *, char *); | |
| +# else | |
| +static PyObject* (*py3_PyCObject_FromVoidPtr)(void *cobj, void (*destr)(void *)); | |
| +static void* (*py3_PyCObject_AsVoidPtr)(PyObject *); | |
| +# endif | |
| # ifdef Py_DEBUG | |
| static void (*py3__Py_NegativeRefcount)(const char *fname, int lineno, PyObject *op); | |
| static Py_ssize_t* py3__Py_RefTotal; | |
| @@ -501,7 +516,9 @@ | |
| {"PyEval_SaveThread", (PYTHON_PROC*)&py3_PyEval_SaveThread}, | |
| {"_PyArg_Parse_SizeT", (PYTHON_PROC*)&py3_PyArg_Parse}, | |
| {"Py_IsInitialized", (PYTHON_PROC*)&py3_Py_IsInitialized}, | |
| +# if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x030100a1 | |
| {"_PyObject_NextNotImplemented", (PYTHON_PROC*)&py3__PyObject_NextNotImplemented}, | |
| +# endif | |
| {"_Py_NoneStruct", (PYTHON_PROC*)&py3__Py_NoneStruct}, | |
| {"_Py_FalseStruct", (PYTHON_PROC*)&py3__Py_FalseStruct}, | |
| {"_Py_TrueStruct", (PYTHON_PROC*)&py3__Py_TrueStruct}, | |
| @@ -559,8 +576,13 @@ | |
| {"PyObject_GC_Del", (PYTHON_PROC*)&py3_PyObject_GC_Del}, | |
| {"PyObject_GC_UnTrack", (PYTHON_PROC*)&py3_PyObject_GC_UnTrack}, | |
| {"PyType_IsSubtype", (PYTHON_PROC*)&py3_PyType_IsSubtype}, | |
| +# ifdef PY_USE_CAPSULE | |
| {"PyCapsule_New", (PYTHON_PROC*)&py3_PyCapsule_New}, | |
| {"PyCapsule_GetPointer", (PYTHON_PROC*)&py3_PyCapsule_GetPointer}, | |
| +# else | |
| + {"PyCObject_FromVoidPtr", (PYTHON_PROC*)&py3_PyCObject_FromVoidPtr}, | |
| + {"PyCObject_AsVoidPtr", (PYTHON_PROC*)&py3_PyCObject_AsVoidPtr}, | |
| +# endif | |
| {"", NULL}, | |
| }; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment