summaryrefslogtreecommitdiff
path: root/src/if_py_both.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-06-12 14:20:36 +0200
committerBram Moolenaar <Bram@vim.org>2013-06-12 14:20:36 +0200
commit9f3685a527c9293b05c8ad7a6a4a7c2fa8b3b8b8 (patch)
tree4a01e3e62a1ecc504d835720319f0a26f71c041c /src/if_py_both.h
parent0ea4a6b94b6f7a13ef5027b43c36bda0836b51af (diff)
downloadvim-git-9f3685a527c9293b05c8ad7a6a4a7c2fa8b3b8b8.tar.gz
updated for version 7.3.1172v7.3.1172
Problem: Python 2: loading modules doesn't work well. Solution: Fix the code. Add more tests. (ZyX)
Diffstat (limited to 'src/if_py_both.h')
-rw-r--r--src/if_py_both.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/if_py_both.h b/src/if_py_both.h
index 1e5a151e7..bd1d70434 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -940,7 +940,6 @@ static struct PyMethodDef VimMethods[] = {
{"foreach_rtp", VimForeachRTP, METH_VARARGS, "Call given callable for each path in &rtp"},
#if PY_MAJOR_VERSION < 3
{"find_module", FinderFindModule, METH_VARARGS, "Internal use only, returns loader object for any input it receives"},
- {"load_module", LoaderLoadModule, METH_VARARGS, "Internal use only, tries importing the given module from &rtp by temporary mocking sys.path (to an rtp-based one) and unsetting sys.meta_path and sys.path_hooks"},
#endif
{"path_hook", VimPathHook, METH_VARARGS, "Hook function to install in sys.path_hooks"},
{"_get_paths", (PyCFunction)Vim_GetPaths, METH_NOARGS, "Get &rtp-based additions to sys.path"},
@@ -5195,6 +5194,13 @@ typedef struct
PyObject_HEAD
} FinderObject;
static PyTypeObject FinderType;
+#else
+typedef struct
+{
+ PyObject_HEAD
+ PyObject *module;
+} LoaderObject;
+static PyTypeObject LoaderType;
#endif
static void
@@ -5444,6 +5450,8 @@ init_types()
PYTYPE_READY(OutputType);
#if PY_MAJOR_VERSION >= 3
PYTYPE_READY(FinderType);
+#else
+ PYTYPE_READY(LoaderType);
#endif
return 0;
}
@@ -5570,6 +5578,8 @@ static struct object_constant {
{"Options", (PyObject *)&OptionsType},
#if PY_MAJOR_VERSION >= 3
{"Finder", (PyObject *)&FinderType},
+#else
+ {"Loader", (PyObject *)&LoaderType},
#endif
};
@@ -5666,6 +5676,9 @@ populate_module(PyObject *m, object_adder add_object, attr_getter get_attr)
ADD_CHECKED_OBJECT(m, "_find_module",
(py_find_module = PyObject_GetAttrString(path_finder,
"find_module")));
+#else
+ ADD_OBJECT(m, "_find_module", py_find_module);
+ ADD_OBJECT(m, "_load_module", py_load_module);
#endif
return 0;