Mercurial > vim
comparison src/if_py_both.h @ 15818:89486329d9e6 v8.1.0916
patch 8.1.0916: with Python 3.7 "find_module" is not made available
commit https://github.com/vim/vim/commit/b999ba2778b6c02fdd100e498a9ba5b2e7036f7d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Feb 14 13:28:45 2019 +0100
patch 8.1.0916: with Python 3.7 "find_module" is not made available
Problem: With Python 3.7 "find_module" is not made available.
Solution: Also add "find_module" with Python 3.7. (Joel Frederico,
closes #3954)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 14 Feb 2019 13:30:14 +0100 |
parents | 6f1c7e9a6393 |
children | bf8cf5c3b784 |
comparison
equal
deleted
inserted
replaced
15817:6fb08ea008b9 | 15818:89486329d9e6 |
---|---|
85 static PyObject *vim_special_path_object; | 85 static PyObject *vim_special_path_object; |
86 | 86 |
87 #if PY_VERSION_HEX >= 0x030700f0 | 87 #if PY_VERSION_HEX >= 0x030700f0 |
88 static PyObject *py_find_spec; | 88 static PyObject *py_find_spec; |
89 #else | 89 #else |
90 static PyObject *py_find_module; | |
91 static PyObject *py_load_module; | 90 static PyObject *py_load_module; |
92 #endif | 91 #endif |
92 static PyObject *py_find_module; | |
93 | 93 |
94 static PyObject *VimError; | 94 static PyObject *VimError; |
95 | 95 |
96 /* | 96 /* |
97 * obtain a lock on the Vim data structures | 97 * obtain a lock on the Vim data structures |
757 | 757 |
758 /* For backwards compatibility numbers are stored as strings. */ | 758 /* For backwards compatibility numbers are stored as strings. */ |
759 sprintf(buf, "%ld", (long)our_tv->vval.v_number); | 759 sprintf(buf, "%ld", (long)our_tv->vval.v_number); |
760 ret = PyString_FromString((char *)buf); | 760 ret = PyString_FromString((char *)buf); |
761 } | 761 } |
762 # ifdef FEAT_FLOAT | 762 #ifdef FEAT_FLOAT |
763 else if (our_tv->v_type == VAR_FLOAT) | 763 else if (our_tv->v_type == VAR_FLOAT) |
764 { | 764 { |
765 char buf[NUMBUFLEN]; | 765 char buf[NUMBUFLEN]; |
766 | 766 |
767 sprintf(buf, "%f", our_tv->vval.v_float); | 767 sprintf(buf, "%f", our_tv->vval.v_float); |
768 ret = PyString_FromString((char *)buf); | 768 ret = PyString_FromString((char *)buf); |
769 } | 769 } |
770 # endif | 770 #endif |
771 else if (our_tv->v_type == VAR_LIST) | 771 else if (our_tv->v_type == VAR_LIST) |
772 { | 772 { |
773 list_T *list = our_tv->vval.v_list; | 773 list_T *list = our_tv->vval.v_list; |
774 listitem_T *curr; | 774 listitem_T *curr; |
775 | 775 |
6091 PyObject *capsule; | 6091 PyObject *capsule; |
6092 char hexBuf[sizeof(void *) * 2 + 3]; | 6092 char hexBuf[sizeof(void *) * 2 + 3]; |
6093 | 6093 |
6094 sprintf(hexBuf, "%p", (void *)obj); | 6094 sprintf(hexBuf, "%p", (void *)obj); |
6095 | 6095 |
6096 # ifdef PY_USE_CAPSULE | 6096 #ifdef PY_USE_CAPSULE |
6097 capsule = PyDict_GetItemString(lookup_dict, hexBuf); | 6097 capsule = PyDict_GetItemString(lookup_dict, hexBuf); |
6098 # else | 6098 #else |
6099 capsule = (PyObject *)PyDict_GetItemString(lookup_dict, hexBuf); | 6099 capsule = (PyObject *)PyDict_GetItemString(lookup_dict, hexBuf); |
6100 # endif | 6100 #endif |
6101 if (capsule == NULL) | 6101 if (capsule == NULL) |
6102 { | 6102 { |
6103 # ifdef PY_USE_CAPSULE | 6103 #ifdef PY_USE_CAPSULE |
6104 capsule = PyCapsule_New(tv, NULL, NULL); | 6104 capsule = PyCapsule_New(tv, NULL, NULL); |
6105 # else | 6105 #else |
6106 capsule = PyCObject_FromVoidPtr(tv, NULL); | 6106 capsule = PyCObject_FromVoidPtr(tv, NULL); |
6107 # endif | 6107 #endif |
6108 if (PyDict_SetItemString(lookup_dict, hexBuf, capsule)) | 6108 if (PyDict_SetItemString(lookup_dict, hexBuf, capsule)) |
6109 { | 6109 { |
6110 Py_DECREF(capsule); | 6110 Py_DECREF(capsule); |
6111 tv->v_type = VAR_UNKNOWN; | 6111 tv->v_type = VAR_UNKNOWN; |
6112 return -1; | 6112 return -1; |
6128 } | 6128 } |
6129 else | 6129 else |
6130 { | 6130 { |
6131 typval_T *v; | 6131 typval_T *v; |
6132 | 6132 |
6133 # ifdef PY_USE_CAPSULE | 6133 #ifdef PY_USE_CAPSULE |
6134 v = PyCapsule_GetPointer(capsule, NULL); | 6134 v = PyCapsule_GetPointer(capsule, NULL); |
6135 # else | 6135 #else |
6136 v = PyCObject_AsVoidPtr(capsule); | 6136 v = PyCObject_AsVoidPtr(capsule); |
6137 # endif | 6137 #endif |
6138 copy_tv(v, tv); | 6138 copy_tv(v, tv); |
6139 } | 6139 } |
6140 return 0; | 6140 return 0; |
6141 } | 6141 } |
6142 | 6142 |
6919 { | 6919 { |
6920 Py_DECREF(imp); | 6920 Py_DECREF(imp); |
6921 return -1; | 6921 return -1; |
6922 } | 6922 } |
6923 | 6923 |
6924 if ((py_find_module = PyObject_GetAttrString(cls, "find_module"))) | |
6925 { | |
6926 // find_module() is deprecated, this may stop working in some later | |
6927 // version. | |
6928 ADD_OBJECT(m, "_find_module", py_find_module); | |
6929 } | |
6930 | |
6924 Py_DECREF(imp); | 6931 Py_DECREF(imp); |
6925 | 6932 |
6926 ADD_OBJECT(m, "_find_spec", py_find_spec); | 6933 ADD_OBJECT(m, "_find_spec", py_find_spec); |
6927 #else | 6934 #else |
6928 if (!(imp = PyImport_ImportModule("imp"))) | 6935 if (!(imp = PyImport_ImportModule("imp"))) |