comparison src/if_python.c @ 15719:3f92851b9a57 v8.1.0867

patch 8.1.0867: cannot build Python interface with Python 2.4 commit https://github.com/vim/vim/commit/65951258d65b71581aeb117dbb7defa8a87ce38f Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 1 22:10:16 2019 +0100 patch 8.1.0867: cannot build Python interface with Python 2.4 Problem: Cannot build Python interface with Python 2.4. (Tom G. Christensen) Solution: Define PyBytes_FromStringAndSize. (Ken Takata, closes https://github.com/vim/vim/issues/3888)
author Bram Moolenaar <Bram@vim.org>
date Fri, 01 Feb 2019 22:15:12 +0100
parents 55ccc2d353bd
children 7fad90423bd2
comparison
equal deleted inserted replaced
15718:648d478405ee 15719:3f92851b9a57
71 #endif 71 #endif
72 72
73 #undef main /* Defined in python.h - aargh */ 73 #undef main /* Defined in python.h - aargh */
74 #undef HAVE_FCNTL_H /* Clash with os_win32.h */ 74 #undef HAVE_FCNTL_H /* Clash with os_win32.h */
75 75
76 // Perhaps leave this out for Python 2.6, which supports bytes?
76 #define PyBytes_FromString PyString_FromString 77 #define PyBytes_FromString PyString_FromString
77 #define PyBytes_Check PyString_Check 78 #define PyBytes_Check PyString_Check
78 #define PyBytes_AsStringAndSize PyString_AsStringAndSize 79 #define PyBytes_AsStringAndSize PyString_AsStringAndSize
80 #define PyBytes_FromStringAndSize PyString_FromStringAndSize
79 81
80 #if !defined(FEAT_PYTHON) && defined(PROTO) 82 #if !defined(FEAT_PYTHON) && defined(PROTO)
81 /* Use this to be able to generate prototypes without python being used. */ 83 /* Use this to be able to generate prototypes without python being used. */
82 # define PyObject Py_ssize_t 84 # define PyObject Py_ssize_t
83 # define PyThreadState Py_ssize_t 85 # define PyThreadState Py_ssize_t
118 #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x020300F0 120 #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x020300F0
119 /* Python 2.3: can invoke ":python" recursively. */ 121 /* Python 2.3: can invoke ":python" recursively. */
120 # define PY_CAN_RECURSE 122 # define PY_CAN_RECURSE
121 #endif 123 #endif
122 124
123 # if defined(DYNAMIC_PYTHON) || defined(PROTO) 125 #if defined(DYNAMIC_PYTHON) || defined(PROTO)
124 # ifndef DYNAMIC_PYTHON 126 # ifndef DYNAMIC_PYTHON
125 # define HINSTANCE long_u /* for generating prototypes */ 127 # define HINSTANCE long_u /* for generating prototypes */
126 # endif 128 # endif
127 129
128 # ifndef WIN3264 130 # ifndef WIN3264
129 # include <dlfcn.h> 131 # include <dlfcn.h>
130 # define FARPROC void* 132 # define FARPROC void*
131 # define HINSTANCE void* 133 # define HINSTANCE void*
487 { 489 {
488 char *name; 490 char *name;
489 PYTHON_PROC *ptr; 491 PYTHON_PROC *ptr;
490 } python_funcname_table[] = 492 } python_funcname_table[] =
491 { 493 {
492 #ifndef PY_SSIZE_T_CLEAN 494 # ifndef PY_SSIZE_T_CLEAN
493 {"PyArg_Parse", (PYTHON_PROC*)&dll_PyArg_Parse}, 495 {"PyArg_Parse", (PYTHON_PROC*)&dll_PyArg_Parse},
494 {"PyArg_ParseTuple", (PYTHON_PROC*)&dll_PyArg_ParseTuple}, 496 {"PyArg_ParseTuple", (PYTHON_PROC*)&dll_PyArg_ParseTuple},
495 {"Py_BuildValue", (PYTHON_PROC*)&dll_Py_BuildValue}, 497 {"Py_BuildValue", (PYTHON_PROC*)&dll_Py_BuildValue},
496 #else 498 # else
497 {"_PyArg_Parse_SizeT", (PYTHON_PROC*)&dll_PyArg_Parse}, 499 {"_PyArg_Parse_SizeT", (PYTHON_PROC*)&dll_PyArg_Parse},
498 {"_PyArg_ParseTuple_SizeT", (PYTHON_PROC*)&dll_PyArg_ParseTuple}, 500 {"_PyArg_ParseTuple_SizeT", (PYTHON_PROC*)&dll_PyArg_ParseTuple},
499 {"_Py_BuildValue_SizeT", (PYTHON_PROC*)&dll_Py_BuildValue}, 501 {"_Py_BuildValue_SizeT", (PYTHON_PROC*)&dll_Py_BuildValue},
500 #endif 502 # endif
501 {"PyMem_Free", (PYTHON_PROC*)&dll_PyMem_Free}, 503 {"PyMem_Free", (PYTHON_PROC*)&dll_PyMem_Free},
502 {"PyMem_Malloc", (PYTHON_PROC*)&dll_PyMem_Malloc}, 504 {"PyMem_Malloc", (PYTHON_PROC*)&dll_PyMem_Malloc},
503 {"PyDict_SetItemString", (PYTHON_PROC*)&dll_PyDict_SetItemString}, 505 {"PyDict_SetItemString", (PYTHON_PROC*)&dll_PyDict_SetItemString},
504 {"PyErr_BadArgument", (PYTHON_PROC*)&dll_PyErr_BadArgument}, 506 {"PyErr_BadArgument", (PYTHON_PROC*)&dll_PyErr_BadArgument},
505 {"PyErr_NewException", (PYTHON_PROC*)&dll_PyErr_NewException}, 507 {"PyErr_NewException", (PYTHON_PROC*)&dll_PyErr_NewException},
676 { 678 {
677 int i; 679 int i;
678 PYTHON_PROC *ucs_as_encoded_string = 680 PYTHON_PROC *ucs_as_encoded_string =
679 (PYTHON_PROC*)&py_PyUnicode_AsEncodedString; 681 (PYTHON_PROC*)&py_PyUnicode_AsEncodedString;
680 682
681 #if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON3) 683 # if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON3)
682 /* Can't have Python and Python3 loaded at the same time. 684 /* Can't have Python and Python3 loaded at the same time.
683 * It cause a crash, because RTLD_GLOBAL is needed for 685 * It cause a crash, because RTLD_GLOBAL is needed for
684 * standard C extension libraries of one or both python versions. */ 686 * standard C extension libraries of one or both python versions. */
685 if (python3_loaded()) 687 if (python3_loaded())
686 { 688 {
687 if (verbose) 689 if (verbose)
688 emsg(_("E836: This Vim cannot execute :python after using :py3")); 690 emsg(_("E836: This Vim cannot execute :python after using :py3"));
689 return FAIL; 691 return FAIL;
690 } 692 }
691 #endif 693 # endif
692 694
693 if (hinstPython) 695 if (hinstPython)
694 return OK; 696 return OK;
695 hinstPython = load_dll(libname); 697 hinstPython = load_dll(libname);
696 if (!hinstPython) 698 if (!hinstPython)