|
Karsten Hopp |
828576 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
828576 |
Subject: Patch 7.3.1163
|
|
Karsten Hopp |
828576 |
Fcc: outbox
|
|
Karsten Hopp |
828576 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
828576 |
Mime-Version: 1.0
|
|
Karsten Hopp |
828576 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
828576 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
828576 |
------------
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
Patch 7.3.1163
|
|
Karsten Hopp |
828576 |
Problem: Not easy to load Python modules.
|
|
Karsten Hopp |
828576 |
Solution: Search "python2", "python3" and "pythonx" directories in
|
|
Karsten Hopp |
828576 |
'runtimepath' for Python modules. (ZyX)
|
|
Karsten Hopp |
828576 |
Files: runtime/doc/if_pyth.txt, src/configure.in, src/ex_cmds2.c,
|
|
Karsten Hopp |
828576 |
src/if_py_both.h, src/if_python.c, src/if_python3.c,
|
|
Karsten Hopp |
828576 |
src/testdir/test86.in, src/testdir/test87.in, src/auto/configure
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
*** ../vim-7.3.1162/runtime/doc/if_pyth.txt 2013-06-02 18:20:12.000000000 +0200
|
|
Karsten Hopp |
828576 |
--- runtime/doc/if_pyth.txt 2013-06-10 20:51:21.000000000 +0200
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 180,185 ****
|
|
Karsten Hopp |
828576 |
--- 180,191 ----
|
|
Karsten Hopp |
828576 |
Like |strwidth()|: returns number of display cells str occupies, tab
|
|
Karsten Hopp |
828576 |
is counted as one cell.
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
+ vim.foreach_rtp(callable) *python-foreach_rtp*
|
|
Karsten Hopp |
828576 |
+ Call the given callable for each path in 'runtimepath' until either
|
|
Karsten Hopp |
828576 |
+ callable returns something but None, the exception is raised or there
|
|
Karsten Hopp |
828576 |
+ are no longer paths. If stopped in case callable returned non-None,
|
|
Karsten Hopp |
828576 |
+ vim.foreach_rtp function returns the value returned by callable.
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
vim.chdir(*args, **kwargs) *python-chdir*
|
|
Karsten Hopp |
828576 |
vim.fchdir(*args, **kwargs) *python-fchdir*
|
|
Karsten Hopp |
828576 |
Run os.chdir or os.fchdir, then all appropriate vim stuff.
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 300,305 ****
|
|
Karsten Hopp |
828576 |
--- 306,418 ----
|
|
Karsten Hopp |
828576 |
supported, and may cause the program to crash. This should probably be
|
|
Karsten Hopp |
828576 |
fixed.
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
+ *python2-directory* *python3-directory* *pythonx-directory*
|
|
Karsten Hopp |
828576 |
+ Python 'runtimepath' handling *python-special-path*
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ In python vim.VIM_SPECIAL_PATH special directory is used as a replacement for
|
|
Karsten Hopp |
828576 |
+ the list of paths found in 'runtimepath': with this directory in sys.path and
|
|
Karsten Hopp |
828576 |
+ vim.path_hooks in sys.path_hooks python will try to load module from
|
|
Karsten Hopp |
828576 |
+ {rtp}/python2 (or python3) and {rtp}/pythonx (for both python versions) for
|
|
Karsten Hopp |
828576 |
+ each {rtp} found in 'runtimepath'.
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ Implementation for python 2 is the following: usual importing code with empty
|
|
Karsten Hopp |
828576 |
+ lists in place of sys.path_hooks and sys.meta_path. Code is similar to the
|
|
Karsten Hopp |
828576 |
+ below, but written in C: >
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ # Assuming vim variable is already accessible and is set to the current
|
|
Karsten Hopp |
828576 |
+ # module
|
|
Karsten Hopp |
828576 |
+ import sys
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ def find_module(fullname):
|
|
Karsten Hopp |
828576 |
+ return vim
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ def load_module(fullname):
|
|
Karsten Hopp |
828576 |
+ # see vim._get_paths below
|
|
Karsten Hopp |
828576 |
+ new_path = _get_paths()
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ try: old_path = sys.path
|
|
Karsten Hopp |
828576 |
+ except: pass
|
|
Karsten Hopp |
828576 |
+ try: old_meta_path = sys.meta_path
|
|
Karsten Hopp |
828576 |
+ except: pass
|
|
Karsten Hopp |
828576 |
+ try: old_path_hooks = sys.path_hooks
|
|
Karsten Hopp |
828576 |
+ except: pass
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ sys.meta_path = []
|
|
Karsten Hopp |
828576 |
+ sys.path_hooks = sys.meta_path
|
|
Karsten Hopp |
828576 |
+ sys.path = new_path
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ try:
|
|
Karsten Hopp |
828576 |
+ exec ('import ' + fullname + ' as m') # No actual exec in C code
|
|
Karsten Hopp |
828576 |
+ return m
|
|
Karsten Hopp |
828576 |
+ finally:
|
|
Karsten Hopp |
828576 |
+ e = None
|
|
Karsten Hopp |
828576 |
+ try: sys.path = old_path
|
|
Karsten Hopp |
828576 |
+ except Exception as e: pass
|
|
Karsten Hopp |
828576 |
+ try: sys.meta_path = old_meta_path
|
|
Karsten Hopp |
828576 |
+ except Exception as e: pass
|
|
Karsten Hopp |
828576 |
+ try: sys.path_hooks = old_path_hooks
|
|
Karsten Hopp |
828576 |
+ except Exception as e: pass
|
|
Karsten Hopp |
828576 |
+ if e:
|
|
Karsten Hopp |
828576 |
+ raise e
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ def path_hook(d):
|
|
Karsten Hopp |
828576 |
+ if d == VIM_SPECIAL_PATH:
|
|
Karsten Hopp |
828576 |
+ return vim
|
|
Karsten Hopp |
828576 |
+ raise ImportError
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ sys.path_hooks.append(path_hook)
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ Implementation for python 3 is cleaner: code is similar to the following, but,
|
|
Karsten Hopp |
828576 |
+ again, written in C: >
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ from importlib.machinery import PathFinder
|
|
Karsten Hopp |
828576 |
+ import sys
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ class Finder(PathFinder):
|
|
Karsten Hopp |
828576 |
+ @classmethod
|
|
Karsten Hopp |
828576 |
+ def find_module(cls, fullname):
|
|
Karsten Hopp |
828576 |
+ # see vim._get_paths below
|
|
Karsten Hopp |
828576 |
+ new_path = _get_paths()
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ # super().find_module is also a class method
|
|
Karsten Hopp |
828576 |
+ # super() is not used because this variant is easier to implement
|
|
Karsten Hopp |
828576 |
+ # in C
|
|
Karsten Hopp |
828576 |
+ return PathFinder.find_module(fullname, new_path)
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ def path_hook(path):
|
|
Karsten Hopp |
828576 |
+ if path == VIM_SPECIAL_PATH:
|
|
Karsten Hopp |
828576 |
+ return Finder
|
|
Karsten Hopp |
828576 |
+ raise ImportError
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ sys.path_hooks.append(path_hook)
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ vim.VIM_SPECIAL_PATH *python-VIM_SPECIAL_PATH*
|
|
Karsten Hopp |
828576 |
+ String constant used in conjunction with vim path hook. If path hook
|
|
Karsten Hopp |
828576 |
+ installed by vim is requested to handle anything but path equal to
|
|
Karsten Hopp |
828576 |
+ vim.VIM_SPECIAL_PATH constant it raises ImportError. In the only other
|
|
Karsten Hopp |
828576 |
+ case it uses special loader.
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ Note: you must not use value of this constant directly, always use
|
|
Karsten Hopp |
828576 |
+ vim.VIM_SPECIAL_PATH object.
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ vim.load_module(name) *python-load_module*
|
|
Karsten Hopp |
828576 |
+ vim.find_module(...) *python-find_module*
|
|
Karsten Hopp |
828576 |
+ vim.path_hook(path) *python-path_hook*
|
|
Karsten Hopp |
828576 |
+ Methods or objects used to implement path loading as described above.
|
|
Karsten Hopp |
828576 |
+ You should not be using any of these directly except for vim.path_hook
|
|
Karsten Hopp |
828576 |
+ in case you need to do something with sys.meta_path. It is not
|
|
Karsten Hopp |
828576 |
+ guaranteed that any of the objects will exist in the future vim
|
|
Karsten Hopp |
828576 |
+ versions. In fact, load_module and find_module methods do not exists
|
|
Karsten Hopp |
828576 |
+ in python3.
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ vim._get_paths *python-_get_paths*
|
|
Karsten Hopp |
828576 |
+ Methods returning a list of paths which will be searched for by path
|
|
Karsten Hopp |
828576 |
+ hook. You should not rely on this method being present in future
|
|
Karsten Hopp |
828576 |
+ versions, but can use it for debugging.
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ It returns a list of {rtp}/python2 (or {rtp}/python3) and
|
|
Karsten Hopp |
828576 |
+ {rtp}/pythonx directories for each {rtp} in 'runtimepath'.
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
==============================================================================
|
|
Karsten Hopp |
828576 |
3. Buffer objects *python-buffer*
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 340,346 ****
|
|
Karsten Hopp |
828576 |
|BufFilePost| autocommands are launched.
|
|
Karsten Hopp |
828576 |
b.number Buffer number. Can be used as |python-buffers| key.
|
|
Karsten Hopp |
828576 |
Read-only.
|
|
Karsten Hopp |
828576 |
! b.valid True or False. Buffer object becames invalid when
|
|
Karsten Hopp |
828576 |
corresponding buffer is wiped out.
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
The buffer object methods are:
|
|
Karsten Hopp |
828576 |
--- 453,459 ----
|
|
Karsten Hopp |
828576 |
|BufFilePost| autocommands are launched.
|
|
Karsten Hopp |
828576 |
b.number Buffer number. Can be used as |python-buffers| key.
|
|
Karsten Hopp |
828576 |
Read-only.
|
|
Karsten Hopp |
828576 |
! b.valid True or False. Buffer object becomes invalid when
|
|
Karsten Hopp |
828576 |
corresponding buffer is wiped out.
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
The buffer object methods are:
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 446,452 ****
|
|
Karsten Hopp |
828576 |
row, col (read-only) On-screen window position in display cells.
|
|
Karsten Hopp |
828576 |
First position is zero.
|
|
Karsten Hopp |
828576 |
tabpage (read-only) Window tab page.
|
|
Karsten Hopp |
828576 |
! valid (read-write) True or False. Window object becames invalid
|
|
Karsten Hopp |
828576 |
when corresponding window is closed.
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
The height attribute is writable only if the screen is split horizontally.
|
|
Karsten Hopp |
828576 |
--- 559,565 ----
|
|
Karsten Hopp |
828576 |
row, col (read-only) On-screen window position in display cells.
|
|
Karsten Hopp |
828576 |
First position is zero.
|
|
Karsten Hopp |
828576 |
tabpage (read-only) Window tab page.
|
|
Karsten Hopp |
828576 |
! valid (read-write) True or False. Window object becomes invalid
|
|
Karsten Hopp |
828576 |
when corresponding window is closed.
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
The height attribute is writable only if the screen is split horizontally.
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 471,477 ****
|
|
Karsten Hopp |
828576 |
windows Like |python-windows|, but for current tab page.
|
|
Karsten Hopp |
828576 |
vars The tab page |t:| variables.
|
|
Karsten Hopp |
828576 |
window Current tabpage window.
|
|
Karsten Hopp |
828576 |
! valid True or False. Tab page object becames invalid when
|
|
Karsten Hopp |
828576 |
corresponding tab page is closed.
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
TabPage object type is available using "TabPage" attribute of vim module.
|
|
Karsten Hopp |
828576 |
--- 584,590 ----
|
|
Karsten Hopp |
828576 |
windows Like |python-windows|, but for current tab page.
|
|
Karsten Hopp |
828576 |
vars The tab page |t:| variables.
|
|
Karsten Hopp |
828576 |
window Current tabpage window.
|
|
Karsten Hopp |
828576 |
! valid True or False. Tab page object becomes invalid when
|
|
Karsten Hopp |
828576 |
corresponding tab page is closed.
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
TabPage object type is available using "TabPage" attribute of vim module.
|
|
Karsten Hopp |
828576 |
*** ../vim-7.3.1162/src/configure.in 2013-06-02 19:14:11.000000000 +0200
|
|
Karsten Hopp |
828576 |
--- src/configure.in 2013-06-10 20:51:21.000000000 +0200
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 863,872 ****
|
|
Karsten Hopp |
828576 |
${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
|
|
Karsten Hopp |
828576 |
]])
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! dnl -- it must be at least version 2.2
|
|
Karsten Hopp |
828576 |
! AC_MSG_CHECKING(Python is 2.2 or better)
|
|
Karsten Hopp |
828576 |
if ${vi_cv_path_python} -c \
|
|
Karsten Hopp |
828576 |
! "import sys; sys.exit(${vi_cv_var_python_version} < 2.2)"
|
|
Karsten Hopp |
828576 |
then
|
|
Karsten Hopp |
828576 |
AC_MSG_RESULT(yep)
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
--- 863,872 ----
|
|
Karsten Hopp |
828576 |
${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
|
|
Karsten Hopp |
828576 |
]])
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! dnl -- it must be at least version 2.3
|
|
Karsten Hopp |
828576 |
! AC_MSG_CHECKING(Python is 2.3 or better)
|
|
Karsten Hopp |
828576 |
if ${vi_cv_path_python} -c \
|
|
Karsten Hopp |
828576 |
! "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
|
|
Karsten Hopp |
828576 |
then
|
|
Karsten Hopp |
828576 |
AC_MSG_RESULT(yep)
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
*** ../vim-7.3.1162/src/ex_cmds2.c 2013-06-10 20:10:40.000000000 +0200
|
|
Karsten Hopp |
828576 |
--- src/ex_cmds2.c 2013-06-10 20:51:21.000000000 +0200
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 2737,2742 ****
|
|
Karsten Hopp |
828576 |
--- 2737,2746 ----
|
|
Karsten Hopp |
828576 |
* When "all" is TRUE repeat for all matches, otherwise only the first one is
|
|
Karsten Hopp |
828576 |
* used.
|
|
Karsten Hopp |
828576 |
* Returns OK when at least one match found, FAIL otherwise.
|
|
Karsten Hopp |
828576 |
+ *
|
|
Karsten Hopp |
828576 |
+ * If "name" is NULL calls callback for each entry in runtimepath. Cookie is
|
|
Karsten Hopp |
828576 |
+ * passed by reference in this case, setting it to NULL indicates that callback
|
|
Karsten Hopp |
828576 |
+ * has done its job.
|
|
Karsten Hopp |
828576 |
*/
|
|
Karsten Hopp |
828576 |
int
|
|
Karsten Hopp |
828576 |
do_in_runtimepath(name, all, callback, cookie)
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 2768,2774 ****
|
|
Karsten Hopp |
828576 |
buf = alloc(MAXPATHL);
|
|
Karsten Hopp |
828576 |
if (buf != NULL && rtp_copy != NULL)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
! if (p_verbose > 1)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
verbose_enter();
|
|
Karsten Hopp |
828576 |
smsg((char_u *)_("Searching for \"%s\" in \"%s\""),
|
|
Karsten Hopp |
828576 |
--- 2772,2778 ----
|
|
Karsten Hopp |
828576 |
buf = alloc(MAXPATHL);
|
|
Karsten Hopp |
828576 |
if (buf != NULL && rtp_copy != NULL)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
! if (p_verbose > 1 && name != NULL)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
verbose_enter();
|
|
Karsten Hopp |
828576 |
smsg((char_u *)_("Searching for \"%s\" in \"%s\""),
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 2782,2788 ****
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
/* Copy the path from 'runtimepath' to buf[]. */
|
|
Karsten Hopp |
828576 |
copy_option_part(&rtp, buf, MAXPATHL, ",");
|
|
Karsten Hopp |
828576 |
! if (STRLEN(buf) + STRLEN(name) + 2 < MAXPATHL)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
add_pathsep(buf);
|
|
Karsten Hopp |
828576 |
tail = buf + STRLEN(buf);
|
|
Karsten Hopp |
828576 |
--- 2786,2798 ----
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
/* Copy the path from 'runtimepath' to buf[]. */
|
|
Karsten Hopp |
828576 |
copy_option_part(&rtp, buf, MAXPATHL, ",");
|
|
Karsten Hopp |
828576 |
! if (name == NULL)
|
|
Karsten Hopp |
828576 |
! {
|
|
Karsten Hopp |
828576 |
! (*callback)(buf, (void *) &cookie);
|
|
Karsten Hopp |
828576 |
! if (!did_one)
|
|
Karsten Hopp |
828576 |
! did_one = (cookie == NULL);
|
|
Karsten Hopp |
828576 |
! }
|
|
Karsten Hopp |
828576 |
! else if (STRLEN(buf) + STRLEN(name) + 2 < MAXPATHL)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
add_pathsep(buf);
|
|
Karsten Hopp |
828576 |
tail = buf + STRLEN(buf);
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 2821,2827 ****
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
vim_free(buf);
|
|
Karsten Hopp |
828576 |
vim_free(rtp_copy);
|
|
Karsten Hopp |
828576 |
! if (p_verbose > 0 && !did_one)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
verbose_enter();
|
|
Karsten Hopp |
828576 |
smsg((char_u *)_("not found in 'runtimepath': \"%s\""), name);
|
|
Karsten Hopp |
828576 |
--- 2831,2837 ----
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
vim_free(buf);
|
|
Karsten Hopp |
828576 |
vim_free(rtp_copy);
|
|
Karsten Hopp |
828576 |
! if (p_verbose > 0 && !did_one && name != NULL)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
verbose_enter();
|
|
Karsten Hopp |
828576 |
smsg((char_u *)_("not found in 'runtimepath': \"%s\""), name);
|
|
Karsten Hopp |
828576 |
*** ../vim-7.3.1162/src/if_py_both.h 2013-06-10 20:47:33.000000000 +0200
|
|
Karsten Hopp |
828576 |
--- src/if_py_both.h 2013-06-10 20:55:17.000000000 +0200
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 24,29 ****
|
|
Karsten Hopp |
828576 |
--- 24,31 ----
|
|
Karsten Hopp |
828576 |
#endif
|
|
Karsten Hopp |
828576 |
#define DOPY_FUNC "_vim_pydo"
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
+ static const char *vim_special_path = "_vim_path_";
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
#define PyErr_SetVim(str) PyErr_SetString(VimError, str)
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
#define RAISE_NO_EMPTY_KEYS PyErr_SetString(PyExc_ValueError, \
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 55,60 ****
|
|
Karsten Hopp |
828576 |
--- 57,64 ----
|
|
Karsten Hopp |
828576 |
static PyObject *py_chdir;
|
|
Karsten Hopp |
828576 |
static PyObject *py_fchdir;
|
|
Karsten Hopp |
828576 |
static PyObject *py_getcwd;
|
|
Karsten Hopp |
828576 |
+ static PyObject *vim_module;
|
|
Karsten Hopp |
828576 |
+ static PyObject *vim_special_path_object;
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/*
|
|
Karsten Hopp |
828576 |
* obtain a lock on the Vim data structures
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 779,797 ****
|
|
Karsten Hopp |
828576 |
return _VimChdir(py_fchdir, args, kwargs);
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/*
|
|
Karsten Hopp |
828576 |
* Vim module - Definitions
|
|
Karsten Hopp |
828576 |
*/
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
static struct PyMethodDef VimMethods[] = {
|
|
Karsten Hopp |
828576 |
! /* name, function, calling, documentation */
|
|
Karsten Hopp |
828576 |
! {"command", VimCommand, METH_VARARGS, "Execute a Vim ex-mode command" },
|
|
Karsten Hopp |
828576 |
! {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" },
|
|
Karsten Hopp |
828576 |
! {"bindeval", VimEvalPy, METH_VARARGS, "Like eval(), but returns objects attached to vim ones"},
|
|
Karsten Hopp |
828576 |
! {"strwidth", VimStrwidth, METH_VARARGS, "Screen string width, counts <Tab> as having width 1"},
|
|
Karsten Hopp |
828576 |
! {"chdir", (PyCFunction)VimChdir, METH_VARARGS|METH_KEYWORDS, "Change directory"},
|
|
Karsten Hopp |
828576 |
! {"fchdir", (PyCFunction)VimFchdir, METH_VARARGS|METH_KEYWORDS, "Change directory"},
|
|
Karsten Hopp |
828576 |
! { NULL, NULL, 0, NULL }
|
|
Karsten Hopp |
828576 |
};
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/*
|
|
Karsten Hopp |
828576 |
--- 783,950 ----
|
|
Karsten Hopp |
828576 |
return _VimChdir(py_fchdir, args, kwargs);
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
+ typedef struct {
|
|
Karsten Hopp |
828576 |
+ PyObject *callable;
|
|
Karsten Hopp |
828576 |
+ PyObject *result;
|
|
Karsten Hopp |
828576 |
+ } map_rtp_data;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ static void
|
|
Karsten Hopp |
828576 |
+ map_rtp_callback(char_u *path, void *_data)
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ void **data = (void **) _data;
|
|
Karsten Hopp |
828576 |
+ PyObject *pathObject;
|
|
Karsten Hopp |
828576 |
+ map_rtp_data *mr_data = *((map_rtp_data **) data);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!(pathObject = PyString_FromString((char *) path)))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ *data = NULL;
|
|
Karsten Hopp |
828576 |
+ return;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ mr_data->result = PyObject_CallFunctionObjArgs(mr_data->callable,
|
|
Karsten Hopp |
828576 |
+ pathObject, NULL);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(pathObject);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!mr_data->result || mr_data->result != Py_None)
|
|
Karsten Hopp |
828576 |
+ *data = NULL;
|
|
Karsten Hopp |
828576 |
+ else
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(mr_data->result);
|
|
Karsten Hopp |
828576 |
+ mr_data->result = NULL;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ static PyObject *
|
|
Karsten Hopp |
828576 |
+ VimForeachRTP(PyObject *self UNUSED, PyObject *args)
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ map_rtp_data data;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!PyArg_ParseTuple(args, "O", &data.callable))
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ data.result = NULL;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ do_in_runtimepath(NULL, FALSE, &map_rtp_callback, &data);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (data.result == NULL)
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ if (PyErr_Occurred())
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+ else
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ Py_INCREF(Py_None);
|
|
Karsten Hopp |
828576 |
+ return Py_None;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+ return data.result;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ /*
|
|
Karsten Hopp |
828576 |
+ * _vim_runtimepath_ special path implementation.
|
|
Karsten Hopp |
828576 |
+ */
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ static void
|
|
Karsten Hopp |
828576 |
+ map_finder_callback(char_u *path, void *_data)
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ void **data = (void **) _data;
|
|
Karsten Hopp |
828576 |
+ PyObject *list = *((PyObject **) data);
|
|
Karsten Hopp |
828576 |
+ PyObject *pathObject1, *pathObject2;
|
|
Karsten Hopp |
828576 |
+ char *pathbuf;
|
|
Karsten Hopp |
828576 |
+ size_t pathlen;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ pathlen = STRLEN(path);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ #if PY_MAJOR_VERSION < 3
|
|
Karsten Hopp |
828576 |
+ # define PY_MAIN_DIR_STRING "python2"
|
|
Karsten Hopp |
828576 |
+ #else
|
|
Karsten Hopp |
828576 |
+ # define PY_MAIN_DIR_STRING "python3"
|
|
Karsten Hopp |
828576 |
+ #endif
|
|
Karsten Hopp |
828576 |
+ #define PY_ALTERNATE_DIR_STRING "pythonx"
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ #define PYTHONX_STRING_LENGTH 7 /* STRLEN("pythonx") */
|
|
Karsten Hopp |
828576 |
+ if (!(pathbuf = PyMem_New(char,
|
|
Karsten Hopp |
828576 |
+ pathlen + STRLEN(PATHSEPSTR) + PYTHONX_STRING_LENGTH + 1)))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ PyErr_NoMemory();
|
|
Karsten Hopp |
828576 |
+ *data = NULL;
|
|
Karsten Hopp |
828576 |
+ return;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ mch_memmove(pathbuf, path, pathlen + 1);
|
|
Karsten Hopp |
828576 |
+ add_pathsep((char_u *) pathbuf);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ pathlen = STRLEN(pathbuf);
|
|
Karsten Hopp |
828576 |
+ mch_memmove(pathbuf + pathlen, PY_MAIN_DIR_STRING,
|
|
Karsten Hopp |
828576 |
+ PYTHONX_STRING_LENGTH + 1);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!(pathObject1 = PyString_FromString(pathbuf)))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ *data = NULL;
|
|
Karsten Hopp |
828576 |
+ PyMem_Free(pathbuf);
|
|
Karsten Hopp |
828576 |
+ return;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ mch_memmove(pathbuf + pathlen, PY_ALTERNATE_DIR_STRING,
|
|
Karsten Hopp |
828576 |
+ PYTHONX_STRING_LENGTH + 1);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!(pathObject2 = PyString_FromString(pathbuf)))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(pathObject1);
|
|
Karsten Hopp |
828576 |
+ PyMem_Free(pathbuf);
|
|
Karsten Hopp |
828576 |
+ *data = NULL;
|
|
Karsten Hopp |
828576 |
+ return;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ PyMem_Free(pathbuf);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (PyList_Append(list, pathObject1)
|
|
Karsten Hopp |
828576 |
+ || PyList_Append(list, pathObject2))
|
|
Karsten Hopp |
828576 |
+ *data = NULL;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(pathObject1);
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(pathObject2);
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ static PyObject *
|
|
Karsten Hopp |
828576 |
+ Vim_GetPaths(PyObject *self UNUSED)
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ PyObject *r;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!(r = PyList_New(0)))
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ do_in_runtimepath(NULL, FALSE, &map_finder_callback, r);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (PyErr_Occurred())
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(r);
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ return r;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
/*
|
|
Karsten Hopp |
828576 |
* Vim module - Definitions
|
|
Karsten Hopp |
828576 |
*/
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
static struct PyMethodDef VimMethods[] = {
|
|
Karsten Hopp |
828576 |
! /* name, function, calling, documentation */
|
|
Karsten Hopp |
828576 |
! {"command", VimCommand, METH_VARARGS, "Execute a Vim ex-mode command" },
|
|
Karsten Hopp |
828576 |
! {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" },
|
|
Karsten Hopp |
828576 |
! {"bindeval", VimEvalPy, METH_VARARGS, "Like eval(), but returns objects attached to vim ones"},
|
|
Karsten Hopp |
828576 |
! {"strwidth", VimStrwidth, METH_VARARGS, "Screen string width, counts <Tab> as having width 1"},
|
|
Karsten Hopp |
828576 |
! {"chdir", (PyCFunction)VimChdir, METH_VARARGS|METH_KEYWORDS, "Change directory"},
|
|
Karsten Hopp |
828576 |
! {"fchdir", (PyCFunction)VimFchdir, METH_VARARGS|METH_KEYWORDS, "Change directory"},
|
|
Karsten Hopp |
828576 |
! {"foreach_rtp", VimForeachRTP, METH_VARARGS, "Call given callable for each path in &rtp"},
|
|
Karsten Hopp |
828576 |
! #if PY_MAJOR_VERSION < 3
|
|
Karsten Hopp |
828576 |
! {"find_module", FinderFindModule, METH_VARARGS, "Internal use only, returns loader object for any input it receives"},
|
|
Karsten Hopp |
828576 |
! {"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"},
|
|
Karsten Hopp |
828576 |
! #endif
|
|
Karsten Hopp |
828576 |
! {"path_hook", VimPathHook, METH_VARARGS, "Hook function to install in sys.path_hooks"},
|
|
Karsten Hopp |
828576 |
! {"_get_paths", (PyCFunction)Vim_GetPaths, METH_NOARGS, "Get &rtp-based additions to sys.path"},
|
|
Karsten Hopp |
828576 |
! { NULL, NULL, 0, NULL}
|
|
Karsten Hopp |
828576 |
};
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/*
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 5036,5041 ****
|
|
Karsten Hopp |
828576 |
--- 5189,5202 ----
|
|
Karsten Hopp |
828576 |
} CurrentObject;
|
|
Karsten Hopp |
828576 |
static PyTypeObject CurrentType;
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
+ #if PY_MAJOR_VERSION >= 3
|
|
Karsten Hopp |
828576 |
+ typedef struct
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ PyObject_HEAD
|
|
Karsten Hopp |
828576 |
+ } FinderObject;
|
|
Karsten Hopp |
828576 |
+ static PyTypeObject FinderType;
|
|
Karsten Hopp |
828576 |
+ #endif
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
static void
|
|
Karsten Hopp |
828576 |
init_structs(void)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 5281,5286 ****
|
|
Karsten Hopp |
828576 |
--- 5442,5522 ----
|
|
Karsten Hopp |
828576 |
PYTYPE_READY(FunctionType);
|
|
Karsten Hopp |
828576 |
PYTYPE_READY(OptionsType);
|
|
Karsten Hopp |
828576 |
PYTYPE_READY(OutputType);
|
|
Karsten Hopp |
828576 |
+ #if PY_MAJOR_VERSION >= 3
|
|
Karsten Hopp |
828576 |
+ PYTYPE_READY(FinderType);
|
|
Karsten Hopp |
828576 |
+ #endif
|
|
Karsten Hopp |
828576 |
+ return 0;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ static int
|
|
Karsten Hopp |
828576 |
+ init_sys_path()
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ PyObject *path;
|
|
Karsten Hopp |
828576 |
+ PyObject *path_hook;
|
|
Karsten Hopp |
828576 |
+ PyObject *path_hooks;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!(path_hook = PyObject_GetAttrString(vim_module, "path_hook")))
|
|
Karsten Hopp |
828576 |
+ return -1;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!(path_hooks = PySys_GetObject("path_hooks")))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ PyErr_Clear();
|
|
Karsten Hopp |
828576 |
+ path_hooks = PyList_New(1);
|
|
Karsten Hopp |
828576 |
+ PyList_SET_ITEM(path_hooks, 0, path_hook);
|
|
Karsten Hopp |
828576 |
+ if (PySys_SetObject("path_hooks", path_hooks))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(path_hooks);
|
|
Karsten Hopp |
828576 |
+ return -1;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(path_hooks);
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+ else if (PyList_Check(path_hooks))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ if (PyList_Append(path_hooks, path_hook))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(path_hook);
|
|
Karsten Hopp |
828576 |
+ return -1;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(path_hook);
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+ else
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ VimTryStart();
|
|
Karsten Hopp |
828576 |
+ EMSG(_("Failed to set path hook: sys.path_hooks is not a list\n"
|
|
Karsten Hopp |
828576 |
+ "You should now do the following:\n"
|
|
Karsten Hopp |
828576 |
+ "- append vim.path_hook to sys.path_hooks\n"
|
|
Karsten Hopp |
828576 |
+ "- append vim.VIM_SPECIAL_PATH to sys.path\n"));
|
|
Karsten Hopp |
828576 |
+ VimTryEnd(); /* Discard the error */
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(path_hook);
|
|
Karsten Hopp |
828576 |
+ return 0;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!(path = PySys_GetObject("path")))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ PyErr_Clear();
|
|
Karsten Hopp |
828576 |
+ path = PyList_New(1);
|
|
Karsten Hopp |
828576 |
+ Py_INCREF(vim_special_path_object);
|
|
Karsten Hopp |
828576 |
+ PyList_SET_ITEM(path, 0, vim_special_path_object);
|
|
Karsten Hopp |
828576 |
+ if (PySys_SetObject("path", path))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(path);
|
|
Karsten Hopp |
828576 |
+ return -1;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(path);
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+ else if (PyList_Check(path))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ if (PyList_Append(path, vim_special_path_object))
|
|
Karsten Hopp |
828576 |
+ return -1;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+ else
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ VimTryStart();
|
|
Karsten Hopp |
828576 |
+ EMSG(_("Failed to set path: sys.path is not a list\n"
|
|
Karsten Hopp |
828576 |
+ "You should now append vim.VIM_SPECIAL_PATH to sys.path"));
|
|
Karsten Hopp |
828576 |
+ VimTryEnd(); /* Discard the error */
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
return 0;
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 5332,5337 ****
|
|
Karsten Hopp |
828576 |
--- 5568,5576 ----
|
|
Karsten Hopp |
828576 |
{"List", (PyObject *)&ListType},
|
|
Karsten Hopp |
828576 |
{"Function", (PyObject *)&FunctionType},
|
|
Karsten Hopp |
828576 |
{"Options", (PyObject *)&OptionsType},
|
|
Karsten Hopp |
828576 |
+ #if PY_MAJOR_VERSION >= 3
|
|
Karsten Hopp |
828576 |
+ {"Finder", (PyObject *)&FinderType},
|
|
Karsten Hopp |
828576 |
+ #endif
|
|
Karsten Hopp |
828576 |
};
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
typedef int (*object_adder)(PyObject *, const char *, PyObject *);
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 5417,5421 ****
|
|
Karsten Hopp |
828576 |
--- 5656,5672 ----
|
|
Karsten Hopp |
828576 |
else
|
|
Karsten Hopp |
828576 |
PyErr_Clear();
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
+ if (!(vim_special_path_object = PyString_FromString(vim_special_path)))
|
|
Karsten Hopp |
828576 |
+ return -1;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ ADD_OBJECT(m, "VIM_SPECIAL_PATH", vim_special_path_object);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ #if PY_MAJOR_VERSION >= 3
|
|
Karsten Hopp |
828576 |
+ ADD_OBJECT(m, "_PathFinder", path_finder);
|
|
Karsten Hopp |
828576 |
+ ADD_CHECKED_OBJECT(m, "_find_module",
|
|
Karsten Hopp |
828576 |
+ (py_find_module = PyObject_GetAttrString(path_finder,
|
|
Karsten Hopp |
828576 |
+ "find_module")));
|
|
Karsten Hopp |
828576 |
+ #endif
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
return 0;
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
*** ../vim-7.3.1162/src/if_python.c 2013-06-10 20:47:33.000000000 +0200
|
|
Karsten Hopp |
828576 |
--- src/if_python.c 2013-06-10 20:55:04.000000000 +0200
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 24,32 ****
|
|
Karsten Hopp |
828576 |
/* uncomment this if used with the debug version of python.
|
|
Karsten Hopp |
828576 |
* Checked on 2.7.4. */
|
|
Karsten Hopp |
828576 |
/* #define Py_DEBUG */
|
|
Karsten Hopp |
828576 |
! /* Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting
|
|
Karsten Hopp |
828576 |
*/
|
|
Karsten Hopp |
828576 |
! /* uncomment this if used with the debug version of python, but without its
|
|
Karsten Hopp |
828576 |
* allocator */
|
|
Karsten Hopp |
828576 |
/* #define Py_DEBUG_NO_PYMALLOC */
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
--- 24,32 ----
|
|
Karsten Hopp |
828576 |
/* uncomment this if used with the debug version of python.
|
|
Karsten Hopp |
828576 |
* Checked on 2.7.4. */
|
|
Karsten Hopp |
828576 |
/* #define Py_DEBUG */
|
|
Karsten Hopp |
828576 |
! /* Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting
|
|
Karsten Hopp |
828576 |
*/
|
|
Karsten Hopp |
828576 |
! /* uncomment this if used with the debug version of python, but without its
|
|
Karsten Hopp |
828576 |
* allocator */
|
|
Karsten Hopp |
828576 |
/* #define Py_DEBUG_NO_PYMALLOC */
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 168,173 ****
|
|
Karsten Hopp |
828576 |
--- 168,174 ----
|
|
Karsten Hopp |
828576 |
# define PyErr_SetNone dll_PyErr_SetNone
|
|
Karsten Hopp |
828576 |
# define PyErr_SetString dll_PyErr_SetString
|
|
Karsten Hopp |
828576 |
# define PyErr_SetObject dll_PyErr_SetObject
|
|
Karsten Hopp |
828576 |
+ # define PyErr_ExceptionMatches dll_PyErr_ExceptionMatches
|
|
Karsten Hopp |
828576 |
# define PyEval_InitThreads dll_PyEval_InitThreads
|
|
Karsten Hopp |
828576 |
# define PyEval_RestoreThread dll_PyEval_RestoreThread
|
|
Karsten Hopp |
828576 |
# define PyEval_SaveThread dll_PyEval_SaveThread
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 184,189 ****
|
|
Karsten Hopp |
828576 |
--- 185,191 ----
|
|
Karsten Hopp |
828576 |
# define PyLong_Type (*dll_PyLong_Type)
|
|
Karsten Hopp |
828576 |
# define PyList_GetItem dll_PyList_GetItem
|
|
Karsten Hopp |
828576 |
# define PyList_Append dll_PyList_Append
|
|
Karsten Hopp |
828576 |
+ # define PyList_Insert dll_PyList_Insert
|
|
Karsten Hopp |
828576 |
# define PyList_New dll_PyList_New
|
|
Karsten Hopp |
828576 |
# define PyList_SetItem dll_PyList_SetItem
|
|
Karsten Hopp |
828576 |
# define PyList_Size dll_PyList_Size
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 233,238 ****
|
|
Karsten Hopp |
828576 |
--- 235,241 ----
|
|
Karsten Hopp |
828576 |
# define PyFloat_Type (*dll_PyFloat_Type)
|
|
Karsten Hopp |
828576 |
# define PyImport_AddModule (*dll_PyImport_AddModule)
|
|
Karsten Hopp |
828576 |
# define PySys_SetObject dll_PySys_SetObject
|
|
Karsten Hopp |
828576 |
+ # define PySys_GetObject dll_PySys_GetObject
|
|
Karsten Hopp |
828576 |
# define PySys_SetArgv dll_PySys_SetArgv
|
|
Karsten Hopp |
828576 |
# define PyType_Type (*dll_PyType_Type)
|
|
Karsten Hopp |
828576 |
# define PyType_Ready (*dll_PyType_Ready)
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 305,310 ****
|
|
Karsten Hopp |
828576 |
--- 308,314 ----
|
|
Karsten Hopp |
828576 |
static void(*dll_PyErr_SetNone)(PyObject *);
|
|
Karsten Hopp |
828576 |
static void(*dll_PyErr_SetString)(PyObject *, const char *);
|
|
Karsten Hopp |
828576 |
static void(*dll_PyErr_SetObject)(PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
+ static int(*dll_PyErr_ExceptionMatches)(PyObject *);
|
|
Karsten Hopp |
828576 |
static void(*dll_PyEval_InitThreads)(void);
|
|
Karsten Hopp |
828576 |
static void(*dll_PyEval_RestoreThread)(PyThreadState *);
|
|
Karsten Hopp |
828576 |
static PyThreadState*(*dll_PyEval_SaveThread)(void);
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 320,326 ****
|
|
Karsten Hopp |
828576 |
static PyTypeObject* dll_PyInt_Type;
|
|
Karsten Hopp |
828576 |
static PyTypeObject* dll_PyLong_Type;
|
|
Karsten Hopp |
828576 |
static PyObject*(*dll_PyList_GetItem)(PyObject *, PyInt);
|
|
Karsten Hopp |
828576 |
! static PyObject*(*dll_PyList_Append)(PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
static PyObject*(*dll_PyList_New)(PyInt size);
|
|
Karsten Hopp |
828576 |
static int(*dll_PyList_SetItem)(PyObject *, PyInt, PyObject *);
|
|
Karsten Hopp |
828576 |
static PyInt(*dll_PyList_Size)(PyObject *);
|
|
Karsten Hopp |
828576 |
--- 324,331 ----
|
|
Karsten Hopp |
828576 |
static PyTypeObject* dll_PyInt_Type;
|
|
Karsten Hopp |
828576 |
static PyTypeObject* dll_PyLong_Type;
|
|
Karsten Hopp |
828576 |
static PyObject*(*dll_PyList_GetItem)(PyObject *, PyInt);
|
|
Karsten Hopp |
828576 |
! static int(*dll_PyList_Append)(PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
! static int(*dll_PyList_Insert)(PyObject *, int, PyObject *);
|
|
Karsten Hopp |
828576 |
static PyObject*(*dll_PyList_New)(PyInt size);
|
|
Karsten Hopp |
828576 |
static int(*dll_PyList_SetItem)(PyObject *, PyInt, PyObject *);
|
|
Karsten Hopp |
828576 |
static PyInt(*dll_PyList_Size)(PyObject *);
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 366,371 ****
|
|
Karsten Hopp |
828576 |
--- 371,377 ----
|
|
Karsten Hopp |
828576 |
static PyObject*(*dll_PyFloat_FromDouble)(double);
|
|
Karsten Hopp |
828576 |
static PyTypeObject* dll_PyFloat_Type;
|
|
Karsten Hopp |
828576 |
static int(*dll_PySys_SetObject)(char *, PyObject *);
|
|
Karsten Hopp |
828576 |
+ static PyObject *(*dll_PySys_GetObject)(char *);
|
|
Karsten Hopp |
828576 |
static int(*dll_PySys_SetArgv)(int, char **);
|
|
Karsten Hopp |
828576 |
static PyTypeObject* dll_PyType_Type;
|
|
Karsten Hopp |
828576 |
static int (*dll_PyType_Ready)(PyTypeObject *type);
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 431,436 ****
|
|
Karsten Hopp |
828576 |
--- 437,443 ----
|
|
Karsten Hopp |
828576 |
static PyObject *imp_PyExc_TypeError;
|
|
Karsten Hopp |
828576 |
static PyObject *imp_PyExc_ValueError;
|
|
Karsten Hopp |
828576 |
static PyObject *imp_PyExc_RuntimeError;
|
|
Karsten Hopp |
828576 |
+ static PyObject *imp_PyExc_ImportError;
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
# define PyExc_AttributeError imp_PyExc_AttributeError
|
|
Karsten Hopp |
828576 |
# define PyExc_IndexError imp_PyExc_IndexError
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 439,444 ****
|
|
Karsten Hopp |
828576 |
--- 446,452 ----
|
|
Karsten Hopp |
828576 |
# define PyExc_TypeError imp_PyExc_TypeError
|
|
Karsten Hopp |
828576 |
# define PyExc_ValueError imp_PyExc_ValueError
|
|
Karsten Hopp |
828576 |
# define PyExc_RuntimeError imp_PyExc_RuntimeError
|
|
Karsten Hopp |
828576 |
+ # define PyExc_ImportError imp_PyExc_ImportError
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/*
|
|
Karsten Hopp |
828576 |
* Table of name to function pointer of python.
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 471,476 ****
|
|
Karsten Hopp |
828576 |
--- 479,485 ----
|
|
Karsten Hopp |
828576 |
{"PyErr_SetNone", (PYTHON_PROC*)&dll_PyErr_SetNone},
|
|
Karsten Hopp |
828576 |
{"PyErr_SetString", (PYTHON_PROC*)&dll_PyErr_SetString},
|
|
Karsten Hopp |
828576 |
{"PyErr_SetObject", (PYTHON_PROC*)&dll_PyErr_SetObject},
|
|
Karsten Hopp |
828576 |
+ {"PyErr_ExceptionMatches", (PYTHON_PROC*)&dll_PyErr_ExceptionMatches},
|
|
Karsten Hopp |
828576 |
{"PyEval_InitThreads", (PYTHON_PROC*)&dll_PyEval_InitThreads},
|
|
Karsten Hopp |
828576 |
{"PyEval_RestoreThread", (PYTHON_PROC*)&dll_PyEval_RestoreThread},
|
|
Karsten Hopp |
828576 |
{"PyEval_SaveThread", (PYTHON_PROC*)&dll_PyEval_SaveThread},
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 487,492 ****
|
|
Karsten Hopp |
828576 |
--- 496,502 ----
|
|
Karsten Hopp |
828576 |
{"PyLong_Type", (PYTHON_PROC*)&dll_PyLong_Type},
|
|
Karsten Hopp |
828576 |
{"PyList_GetItem", (PYTHON_PROC*)&dll_PyList_GetItem},
|
|
Karsten Hopp |
828576 |
{"PyList_Append", (PYTHON_PROC*)&dll_PyList_Append},
|
|
Karsten Hopp |
828576 |
+ {"PyList_Insert", (PYTHON_PROC*)&dll_PyList_Insert},
|
|
Karsten Hopp |
828576 |
{"PyList_New", (PYTHON_PROC*)&dll_PyList_New},
|
|
Karsten Hopp |
828576 |
{"PyList_SetItem", (PYTHON_PROC*)&dll_PyList_SetItem},
|
|
Karsten Hopp |
828576 |
{"PyList_Size", (PYTHON_PROC*)&dll_PyList_Size},
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 532,537 ****
|
|
Karsten Hopp |
828576 |
--- 542,548 ----
|
|
Karsten Hopp |
828576 |
{"PyFloat_FromDouble", (PYTHON_PROC*)&dll_PyFloat_FromDouble},
|
|
Karsten Hopp |
828576 |
{"PyImport_AddModule", (PYTHON_PROC*)&dll_PyImport_AddModule},
|
|
Karsten Hopp |
828576 |
{"PySys_SetObject", (PYTHON_PROC*)&dll_PySys_SetObject},
|
|
Karsten Hopp |
828576 |
+ {"PySys_GetObject", (PYTHON_PROC*)&dll_PySys_GetObject},
|
|
Karsten Hopp |
828576 |
{"PySys_SetArgv", (PYTHON_PROC*)&dll_PySys_SetArgv},
|
|
Karsten Hopp |
828576 |
{"PyType_Type", (PYTHON_PROC*)&dll_PyType_Type},
|
|
Karsten Hopp |
828576 |
{"PyType_Ready", (PYTHON_PROC*)&dll_PyType_Ready},
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 706,711 ****
|
|
Karsten Hopp |
828576 |
--- 717,723 ----
|
|
Karsten Hopp |
828576 |
imp_PyExc_TypeError = PyDict_GetItemString(exdict, "TypeError");
|
|
Karsten Hopp |
828576 |
imp_PyExc_ValueError = PyDict_GetItemString(exdict, "ValueError");
|
|
Karsten Hopp |
828576 |
imp_PyExc_RuntimeError = PyDict_GetItemString(exdict, "RuntimeError");
|
|
Karsten Hopp |
828576 |
+ imp_PyExc_ImportError = PyDict_GetItemString(exdict, "ImportError");
|
|
Karsten Hopp |
828576 |
Py_XINCREF(imp_PyExc_AttributeError);
|
|
Karsten Hopp |
828576 |
Py_XINCREF(imp_PyExc_IndexError);
|
|
Karsten Hopp |
828576 |
Py_XINCREF(imp_PyExc_KeyError);
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 713,718 ****
|
|
Karsten Hopp |
828576 |
--- 725,731 ----
|
|
Karsten Hopp |
828576 |
Py_XINCREF(imp_PyExc_TypeError);
|
|
Karsten Hopp |
828576 |
Py_XINCREF(imp_PyExc_ValueError);
|
|
Karsten Hopp |
828576 |
Py_XINCREF(imp_PyExc_RuntimeError);
|
|
Karsten Hopp |
828576 |
+ Py_XINCREF(imp_PyExc_ImportError);
|
|
Karsten Hopp |
828576 |
Py_XDECREF(exmod);
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
#endif /* DYNAMIC_PYTHON */
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 735,740 ****
|
|
Karsten Hopp |
828576 |
--- 748,757 ----
|
|
Karsten Hopp |
828576 |
static PyObject *ListGetattr(PyObject *, char *);
|
|
Karsten Hopp |
828576 |
static PyObject *FunctionGetattr(PyObject *, char *);
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
+ static PyObject *LoaderLoadModule(PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
+ static PyObject *FinderFindModule(PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
+ static PyObject *VimPathHook(PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
#ifndef Py_VISIT
|
|
Karsten Hopp |
828576 |
# define Py_VISIT(obj) visit(obj, arg)
|
|
Karsten Hopp |
828576 |
#endif
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 1359,1369 ****
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
#endif
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
static int
|
|
Karsten Hopp |
828576 |
PythonMod_Init(void)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
- PyObject *mod;
|
|
Karsten Hopp |
828576 |
-
|
|
Karsten Hopp |
828576 |
/* The special value is removed from sys.path in Python_Init(). */
|
|
Karsten Hopp |
828576 |
static char *(argv[2]) = {"/must>not&exist/foo", NULL};
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
--- 1376,1487 ----
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
#endif
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
+ static PyObject *
|
|
Karsten Hopp |
828576 |
+ LoaderLoadModule(PyObject *self, PyObject *args)
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ char *fullname;
|
|
Karsten Hopp |
828576 |
+ PyObject *path;
|
|
Karsten Hopp |
828576 |
+ PyObject *meta_path;
|
|
Karsten Hopp |
828576 |
+ PyObject *path_hooks;
|
|
Karsten Hopp |
828576 |
+ PyObject *new_path;
|
|
Karsten Hopp |
828576 |
+ PyObject *r;
|
|
Karsten Hopp |
828576 |
+ PyObject *new_list;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!PyArg_ParseTuple(args, "s", &fullname))
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!(new_path = Vim_GetPaths(self)))
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!(new_list = PyList_New(0)))
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ #define GET_SYS_OBJECT(objstr, obj) \
|
|
Karsten Hopp |
828576 |
+ obj = PySys_GetObject(objstr); \
|
|
Karsten Hopp |
828576 |
+ PyErr_Clear(); \
|
|
Karsten Hopp |
828576 |
+ Py_XINCREF(obj);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ GET_SYS_OBJECT("meta_path", meta_path);
|
|
Karsten Hopp |
828576 |
+ if (PySys_SetObject("meta_path", new_list))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ Py_XDECREF(meta_path);
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(new_list);
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(new_list); /* Now it becomes a reference borrowed from
|
|
Karsten Hopp |
828576 |
+ sys.meta_path */
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ #define RESTORE_SYS_OBJECT(objstr, obj) \
|
|
Karsten Hopp |
828576 |
+ if (obj) \
|
|
Karsten Hopp |
828576 |
+ { \
|
|
Karsten Hopp |
828576 |
+ PySys_SetObject(objstr, obj); \
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(obj); \
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ GET_SYS_OBJECT("path_hooks", path_hooks);
|
|
Karsten Hopp |
828576 |
+ if (PySys_SetObject("path_hooks", new_list))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ RESTORE_SYS_OBJECT("meta_path", meta_path);
|
|
Karsten Hopp |
828576 |
+ Py_XDECREF(path_hooks);
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ GET_SYS_OBJECT("path", path);
|
|
Karsten Hopp |
828576 |
+ if (PySys_SetObject("path", new_path))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ RESTORE_SYS_OBJECT("meta_path", meta_path);
|
|
Karsten Hopp |
828576 |
+ RESTORE_SYS_OBJECT("path_hooks", path_hooks);
|
|
Karsten Hopp |
828576 |
+ Py_XDECREF(path);
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(new_path);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ r = PyImport_ImportModule(fullname);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ RESTORE_SYS_OBJECT("meta_path", meta_path);
|
|
Karsten Hopp |
828576 |
+ RESTORE_SYS_OBJECT("path_hooks", path_hooks);
|
|
Karsten Hopp |
828576 |
+ RESTORE_SYS_OBJECT("path", path);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (PyErr_Occurred())
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ Py_XDECREF(r);
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ return r;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ static PyObject *
|
|
Karsten Hopp |
828576 |
+ FinderFindModule(PyObject *self UNUSED, PyObject *args UNUSED)
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ /*
|
|
Karsten Hopp |
828576 |
+ * Don't bother actually finding the module, it is delegated to the "loader"
|
|
Karsten Hopp |
828576 |
+ * object (which is basically the same object: vim module).
|
|
Karsten Hopp |
828576 |
+ */
|
|
Karsten Hopp |
828576 |
+ Py_INCREF(vim_module);
|
|
Karsten Hopp |
828576 |
+ return vim_module;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ static PyObject *
|
|
Karsten Hopp |
828576 |
+ VimPathHook(PyObject *self UNUSED, PyObject *args)
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ char *path;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (PyArg_ParseTuple(args, "s", &path)
|
|
Karsten Hopp |
828576 |
+ && STRCMP(path, vim_special_path) == 0)
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ Py_INCREF(vim_module);
|
|
Karsten Hopp |
828576 |
+ return vim_module;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ PyErr_Clear();
|
|
Karsten Hopp |
828576 |
+ PyErr_SetNone(PyExc_ImportError);
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
static int
|
|
Karsten Hopp |
828576 |
PythonMod_Init(void)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
/* The special value is removed from sys.path in Python_Init(). */
|
|
Karsten Hopp |
828576 |
static char *(argv[2]) = {"/must>not&exist/foo", NULL};
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 1373,1382 ****
|
|
Karsten Hopp |
828576 |
/* Set sys.argv[] to avoid a crash in warn(). */
|
|
Karsten Hopp |
828576 |
PySys_SetArgv(1, argv);
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL,
|
|
Karsten Hopp |
828576 |
! PYTHON_API_VERSION);
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! return populate_module(mod, PyModule_AddObject, PyObject_GetAttrString);
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/*************************************************************************
|
|
Karsten Hopp |
828576 |
--- 1491,1507 ----
|
|
Karsten Hopp |
828576 |
/* Set sys.argv[] to avoid a crash in warn(). */
|
|
Karsten Hopp |
828576 |
PySys_SetArgv(1, argv);
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! vim_module = Py_InitModule4("vim", VimMethods, (char *)NULL,
|
|
Karsten Hopp |
828576 |
! (PyObject *)NULL, PYTHON_API_VERSION);
|
|
Karsten Hopp |
828576 |
!
|
|
Karsten Hopp |
828576 |
! if (populate_module(vim_module, PyModule_AddObject,
|
|
Karsten Hopp |
828576 |
! PyObject_GetAttrString))
|
|
Karsten Hopp |
828576 |
! return -1;
|
|
Karsten Hopp |
828576 |
!
|
|
Karsten Hopp |
828576 |
! if (init_sys_path())
|
|
Karsten Hopp |
828576 |
! return -1;
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! return 0;
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/*************************************************************************
|
|
Karsten Hopp |
828576 |
*** ../vim-7.3.1162/src/if_python3.c 2013-06-10 18:36:20.000000000 +0200
|
|
Karsten Hopp |
828576 |
--- src/if_python3.c 2013-06-10 20:55:44.000000000 +0200
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 134,139 ****
|
|
Karsten Hopp |
828576 |
--- 134,140 ----
|
|
Karsten Hopp |
828576 |
# define PyErr_SetNone py3_PyErr_SetNone
|
|
Karsten Hopp |
828576 |
# define PyErr_SetString py3_PyErr_SetString
|
|
Karsten Hopp |
828576 |
# define PyErr_SetObject py3_PyErr_SetObject
|
|
Karsten Hopp |
828576 |
+ # define PyErr_ExceptionMatches py3_PyErr_ExceptionMatches
|
|
Karsten Hopp |
828576 |
# define PyEval_InitThreads py3_PyEval_InitThreads
|
|
Karsten Hopp |
828576 |
# define PyEval_RestoreThread py3_PyEval_RestoreThread
|
|
Karsten Hopp |
828576 |
# define PyEval_SaveThread py3_PyEval_SaveThread
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 143,148 ****
|
|
Karsten Hopp |
828576 |
--- 144,150 ----
|
|
Karsten Hopp |
828576 |
# define PyLong_FromLong py3_PyLong_FromLong
|
|
Karsten Hopp |
828576 |
# define PyList_GetItem py3_PyList_GetItem
|
|
Karsten Hopp |
828576 |
# define PyList_Append py3_PyList_Append
|
|
Karsten Hopp |
828576 |
+ # define PyList_Insert py3_PyList_Insert
|
|
Karsten Hopp |
828576 |
# define PyList_New py3_PyList_New
|
|
Karsten Hopp |
828576 |
# define PyList_SetItem py3_PyList_SetItem
|
|
Karsten Hopp |
828576 |
# define PyList_Size py3_PyList_Size
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 177,182 ****
|
|
Karsten Hopp |
828576 |
--- 179,185 ----
|
|
Karsten Hopp |
828576 |
# define PyEval_GetLocals py3_PyEval_GetLocals
|
|
Karsten Hopp |
828576 |
# define PyEval_GetGlobals py3_PyEval_GetGlobals
|
|
Karsten Hopp |
828576 |
# define PySys_SetObject py3_PySys_SetObject
|
|
Karsten Hopp |
828576 |
+ # define PySys_GetObject py3_PySys_GetObject
|
|
Karsten Hopp |
828576 |
# define PySys_SetArgv py3_PySys_SetArgv
|
|
Karsten Hopp |
828576 |
# define PyType_Ready py3_PyType_Ready
|
|
Karsten Hopp |
828576 |
#undef Py_BuildValue
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 268,274 ****
|
|
Karsten Hopp |
828576 |
static PyGILState_STATE (*py3_PyGILState_Ensure)(void);
|
|
Karsten Hopp |
828576 |
static void (*py3_PyGILState_Release)(PyGILState_STATE);
|
|
Karsten Hopp |
828576 |
static int (*py3_PySys_SetObject)(char *, PyObject *);
|
|
Karsten Hopp |
828576 |
! static PyObject* (*py3_PyList_Append)(PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
static Py_ssize_t (*py3_PyList_Size)(PyObject *);
|
|
Karsten Hopp |
828576 |
static int (*py3_PySequence_Check)(PyObject *);
|
|
Karsten Hopp |
828576 |
static Py_ssize_t (*py3_PySequence_Size)(PyObject *);
|
|
Karsten Hopp |
828576 |
--- 271,279 ----
|
|
Karsten Hopp |
828576 |
static PyGILState_STATE (*py3_PyGILState_Ensure)(void);
|
|
Karsten Hopp |
828576 |
static void (*py3_PyGILState_Release)(PyGILState_STATE);
|
|
Karsten Hopp |
828576 |
static int (*py3_PySys_SetObject)(char *, PyObject *);
|
|
Karsten Hopp |
828576 |
! static PyObject* (*py3_PySys_GetObject)(char *);
|
|
Karsten Hopp |
828576 |
! static int (*py3_PyList_Append)(PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
! static int (*py3_PyList_Insert)(PyObject *, int, PyObject *);
|
|
Karsten Hopp |
828576 |
static Py_ssize_t (*py3_PyList_Size)(PyObject *);
|
|
Karsten Hopp |
828576 |
static int (*py3_PySequence_Check)(PyObject *);
|
|
Karsten Hopp |
828576 |
static Py_ssize_t (*py3_PySequence_Size)(PyObject *);
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 284,289 ****
|
|
Karsten Hopp |
828576 |
--- 289,295 ----
|
|
Karsten Hopp |
828576 |
static void (*py3_Py_Finalize)(void);
|
|
Karsten Hopp |
828576 |
static void (*py3_PyErr_SetString)(PyObject *, const char *);
|
|
Karsten Hopp |
828576 |
static void (*py3_PyErr_SetObject)(PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
+ static int (*py3_PyErr_ExceptionMatches)(PyObject *);
|
|
Karsten Hopp |
828576 |
static int (*py3_PyRun_SimpleString)(char *);
|
|
Karsten Hopp |
828576 |
static PyObject* (*py3_PyRun_String)(char *, int, PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
static PyObject* (*py3_PyObject_GetAttrString)(PyObject *, const char *);
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 393,398 ****
|
|
Karsten Hopp |
828576 |
--- 399,405 ----
|
|
Karsten Hopp |
828576 |
static PyObject *p3imp_PyExc_TypeError;
|
|
Karsten Hopp |
828576 |
static PyObject *p3imp_PyExc_ValueError;
|
|
Karsten Hopp |
828576 |
static PyObject *p3imp_PyExc_RuntimeError;
|
|
Karsten Hopp |
828576 |
+ static PyObject *p3imp_PyExc_ImportError;
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
# define PyExc_AttributeError p3imp_PyExc_AttributeError
|
|
Karsten Hopp |
828576 |
# define PyExc_IndexError p3imp_PyExc_IndexError
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 401,406 ****
|
|
Karsten Hopp |
828576 |
--- 408,414 ----
|
|
Karsten Hopp |
828576 |
# define PyExc_TypeError p3imp_PyExc_TypeError
|
|
Karsten Hopp |
828576 |
# define PyExc_ValueError p3imp_PyExc_ValueError
|
|
Karsten Hopp |
828576 |
# define PyExc_RuntimeError p3imp_PyExc_RuntimeError
|
|
Karsten Hopp |
828576 |
+ # define PyExc_ImportError p3imp_PyExc_ImportError
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/*
|
|
Karsten Hopp |
828576 |
* Table of name to function pointer of python.
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 428,434 ****
|
|
Karsten Hopp |
828576 |
--- 436,444 ----
|
|
Karsten Hopp |
828576 |
{"PyGILState_Ensure", (PYTHON_PROC*)&py3_PyGILState_Ensure},
|
|
Karsten Hopp |
828576 |
{"PyGILState_Release", (PYTHON_PROC*)&py3_PyGILState_Release},
|
|
Karsten Hopp |
828576 |
{"PySys_SetObject", (PYTHON_PROC*)&py3_PySys_SetObject},
|
|
Karsten Hopp |
828576 |
+ {"PySys_GetObject", (PYTHON_PROC*)&py3_PySys_GetObject},
|
|
Karsten Hopp |
828576 |
{"PyList_Append", (PYTHON_PROC*)&py3_PyList_Append},
|
|
Karsten Hopp |
828576 |
+ {"PyList_Insert", (PYTHON_PROC*)&py3_PyList_Insert},
|
|
Karsten Hopp |
828576 |
{"PyList_Size", (PYTHON_PROC*)&py3_PyList_Size},
|
|
Karsten Hopp |
828576 |
{"PySequence_Check", (PYTHON_PROC*)&py3_PySequence_Check},
|
|
Karsten Hopp |
828576 |
{"PySequence_Size", (PYTHON_PROC*)&py3_PySequence_Size},
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 441,446 ****
|
|
Karsten Hopp |
828576 |
--- 451,457 ----
|
|
Karsten Hopp |
828576 |
{"Py_Finalize", (PYTHON_PROC*)&py3_Py_Finalize},
|
|
Karsten Hopp |
828576 |
{"PyErr_SetString", (PYTHON_PROC*)&py3_PyErr_SetString},
|
|
Karsten Hopp |
828576 |
{"PyErr_SetObject", (PYTHON_PROC*)&py3_PyErr_SetObject},
|
|
Karsten Hopp |
828576 |
+ {"PyErr_ExceptionMatches", (PYTHON_PROC*)&py3_PyErr_ExceptionMatches},
|
|
Karsten Hopp |
828576 |
{"PyRun_SimpleString", (PYTHON_PROC*)&py3_PyRun_SimpleString},
|
|
Karsten Hopp |
828576 |
{"PyRun_String", (PYTHON_PROC*)&py3_PyRun_String},
|
|
Karsten Hopp |
828576 |
{"PyObject_GetAttrString", (PYTHON_PROC*)&py3_PyObject_GetAttrString},
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 664,669 ****
|
|
Karsten Hopp |
828576 |
--- 675,681 ----
|
|
Karsten Hopp |
828576 |
p3imp_PyExc_TypeError = PyDict_GetItemString(exdict, "TypeError");
|
|
Karsten Hopp |
828576 |
p3imp_PyExc_ValueError = PyDict_GetItemString(exdict, "ValueError");
|
|
Karsten Hopp |
828576 |
p3imp_PyExc_RuntimeError = PyDict_GetItemString(exdict, "RuntimeError");
|
|
Karsten Hopp |
828576 |
+ p3imp_PyExc_ImportError = PyDict_GetItemString(exdict, "ImportError");
|
|
Karsten Hopp |
828576 |
Py_XINCREF(p3imp_PyExc_AttributeError);
|
|
Karsten Hopp |
828576 |
Py_XINCREF(p3imp_PyExc_IndexError);
|
|
Karsten Hopp |
828576 |
Py_XINCREF(p3imp_PyExc_KeyError);
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 671,676 ****
|
|
Karsten Hopp |
828576 |
--- 683,689 ----
|
|
Karsten Hopp |
828576 |
Py_XINCREF(p3imp_PyExc_TypeError);
|
|
Karsten Hopp |
828576 |
Py_XINCREF(p3imp_PyExc_ValueError);
|
|
Karsten Hopp |
828576 |
Py_XINCREF(p3imp_PyExc_RuntimeError);
|
|
Karsten Hopp |
828576 |
+ Py_XINCREF(p3imp_PyExc_ImportError);
|
|
Karsten Hopp |
828576 |
Py_XDECREF(exmod);
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
#endif /* DYNAMIC_PYTHON3 */
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 723,730 ****
|
|
Karsten Hopp |
828576 |
--- 736,748 ----
|
|
Karsten Hopp |
828576 |
static int ListSetattro(PyObject *, PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
static PyObject *FunctionGetattro(PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
+ static PyObject *VimPathHook(PyObject *, PyObject *);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
static struct PyModuleDef vimmodule;
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
+ static PyObject *path_finder;
|
|
Karsten Hopp |
828576 |
+ static PyObject *py_find_module = NULL;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
#define PY_CAN_RECURSE
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/*
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 1585,1596 ****
|
|
Karsten Hopp |
828576 |
#endif
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
static PyObject *
|
|
Karsten Hopp |
828576 |
! Py3Init_vim(void)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
! PyObject *mod;
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/* The special value is removed from sys.path in Python3_Init(). */
|
|
Karsten Hopp |
828576 |
static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL};
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
if (init_types())
|
|
Karsten Hopp |
828576 |
return NULL;
|
|
Karsten Hopp |
828576 |
--- 1603,1672 ----
|
|
Karsten Hopp |
828576 |
#endif
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
static PyObject *
|
|
Karsten Hopp |
828576 |
! VimPathHook(PyObject *self UNUSED, PyObject *args)
|
|
Karsten Hopp |
828576 |
{
|
|
Karsten Hopp |
828576 |
! char *path;
|
|
Karsten Hopp |
828576 |
!
|
|
Karsten Hopp |
828576 |
! if (PyArg_ParseTuple(args, "s", &path)
|
|
Karsten Hopp |
828576 |
! && STRCMP(path, vim_special_path) == 0)
|
|
Karsten Hopp |
828576 |
! {
|
|
Karsten Hopp |
828576 |
! Py_INCREF(&FinderType);
|
|
Karsten Hopp |
828576 |
! return (PyObject *) &FinderType;
|
|
Karsten Hopp |
828576 |
! }
|
|
Karsten Hopp |
828576 |
!
|
|
Karsten Hopp |
828576 |
! PyErr_Clear();
|
|
Karsten Hopp |
828576 |
! PyErr_SetNone(PyExc_ImportError);
|
|
Karsten Hopp |
828576 |
! return NULL;
|
|
Karsten Hopp |
828576 |
! }
|
|
Karsten Hopp |
828576 |
!
|
|
Karsten Hopp |
828576 |
! static PyObject *
|
|
Karsten Hopp |
828576 |
! FinderFindModule(PyObject *cls UNUSED, PyObject *fullname)
|
|
Karsten Hopp |
828576 |
! {
|
|
Karsten Hopp |
828576 |
! PyObject *new_path;
|
|
Karsten Hopp |
828576 |
! PyObject *r;
|
|
Karsten Hopp |
828576 |
!
|
|
Karsten Hopp |
828576 |
! if (!(new_path = Vim_GetPaths(NULL)))
|
|
Karsten Hopp |
828576 |
! return NULL;
|
|
Karsten Hopp |
828576 |
!
|
|
Karsten Hopp |
828576 |
! /* call find_module of the super() class */
|
|
Karsten Hopp |
828576 |
! r = PyObject_CallFunctionObjArgs(py_find_module, fullname, new_path, NULL);
|
|
Karsten Hopp |
828576 |
!
|
|
Karsten Hopp |
828576 |
! Py_DECREF(new_path);
|
|
Karsten Hopp |
828576 |
!
|
|
Karsten Hopp |
828576 |
! return r;
|
|
Karsten Hopp |
828576 |
! }
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
+ static struct PyMethodDef FinderMethods[] = {
|
|
Karsten Hopp |
828576 |
+ {"find_module", FinderFindModule, METH_CLASS|METH_O, ""},
|
|
Karsten Hopp |
828576 |
+ {NULL, NULL, 0, NULL}
|
|
Karsten Hopp |
828576 |
+ };
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ static PyObject *
|
|
Karsten Hopp |
828576 |
+ Py3Init_vim(void)
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
/* The special value is removed from sys.path in Python3_Init(). */
|
|
Karsten Hopp |
828576 |
static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL};
|
|
Karsten Hopp |
828576 |
+ PyObject *importlib_machinery;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!(importlib_machinery = PyImport_ImportModule("importlib.machinery")))
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ if (!(path_finder = PyObject_GetAttrString(importlib_machinery,
|
|
Karsten Hopp |
828576 |
+ "PathFinder")))
|
|
Karsten Hopp |
828576 |
+ {
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(importlib_machinery);
|
|
Karsten Hopp |
828576 |
+ return NULL;
|
|
Karsten Hopp |
828576 |
+ }
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ Py_DECREF(importlib_machinery);
|
|
Karsten Hopp |
828576 |
+
|
|
Karsten Hopp |
828576 |
+ vim_memset(&FinderType, 0, sizeof(FinderObject));
|
|
Karsten Hopp |
828576 |
+ FinderType.tp_name = "vim.Finder";
|
|
Karsten Hopp |
828576 |
+ FinderType.tp_basicsize = sizeof(FinderObject);
|
|
Karsten Hopp |
828576 |
+ FinderType.tp_base = (PyTypeObject *) path_finder;
|
|
Karsten Hopp |
828576 |
+ FinderType.tp_flags = Py_TPFLAGS_DEFAULT;
|
|
Karsten Hopp |
828576 |
+ FinderType.tp_doc = "Vim finder class, for use with path hook";
|
|
Karsten Hopp |
828576 |
+ FinderType.tp_methods = FinderMethods;
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
if (init_types())
|
|
Karsten Hopp |
828576 |
return NULL;
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 1598,1611 ****
|
|
Karsten Hopp |
828576 |
/* Set sys.argv[] to avoid a crash in warn(). */
|
|
Karsten Hopp |
828576 |
PySys_SetArgv(1, argv);
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! mod = PyModule_Create(&vimmodule);
|
|
Karsten Hopp |
828576 |
! if (mod == NULL)
|
|
Karsten Hopp |
828576 |
return NULL;
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! if (populate_module(mod, PyModule_AddObject, PyObject_GetAttrString))
|
|
Karsten Hopp |
828576 |
return NULL;
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! return mod;
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/*************************************************************************
|
|
Karsten Hopp |
828576 |
--- 1674,1689 ----
|
|
Karsten Hopp |
828576 |
/* Set sys.argv[] to avoid a crash in warn(). */
|
|
Karsten Hopp |
828576 |
PySys_SetArgv(1, argv);
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! if ((vim_module = PyModule_Create(&vimmodule)) == NULL)
|
|
Karsten Hopp |
828576 |
! return NULL;
|
|
Karsten Hopp |
828576 |
!
|
|
Karsten Hopp |
828576 |
! if (populate_module(vim_module, PyModule_AddObject, PyObject_GetAttrString))
|
|
Karsten Hopp |
828576 |
return NULL;
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! if (init_sys_path())
|
|
Karsten Hopp |
828576 |
return NULL;
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! return vim_module;
|
|
Karsten Hopp |
828576 |
}
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/*************************************************************************
|
|
Karsten Hopp |
828576 |
*** ../vim-7.3.1162/src/testdir/test86.in 2013-06-02 18:54:16.000000000 +0200
|
|
Karsten Hopp |
828576 |
--- src/testdir/test86.in 2013-06-10 21:05:44.000000000 +0200
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 1069,1074 ****
|
|
Karsten Hopp |
828576 |
--- 1069,1082 ----
|
|
Karsten Hopp |
828576 |
ee('vim.current.xxx = True')
|
|
Karsten Hopp |
828576 |
EOF
|
|
Karsten Hopp |
828576 |
:"
|
|
Karsten Hopp |
828576 |
+ :" Test import TODO: BROKEN
|
|
Karsten Hopp |
828576 |
+ :"py << EOF
|
|
Karsten Hopp |
828576 |
+ :"vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\')
|
|
Karsten Hopp |
828576 |
+ :"from module import dir as d
|
|
Karsten Hopp |
828576 |
+ :"from modulex import ddir
|
|
Karsten Hopp |
828576 |
+ :"cb.append(d + ',' + ddir)
|
|
Karsten Hopp |
828576 |
+ :"EOF
|
|
Karsten Hopp |
828576 |
+ :"
|
|
Karsten Hopp |
828576 |
:" Test exceptions
|
|
Karsten Hopp |
828576 |
:fun Exe(e)
|
|
Karsten Hopp |
828576 |
: execute a:e
|
|
Karsten Hopp |
828576 |
*** ../vim-7.3.1162/src/testdir/test87.in 2013-06-02 18:54:16.000000000 +0200
|
|
Karsten Hopp |
828576 |
--- src/testdir/test87.in 2013-06-10 21:06:37.000000000 +0200
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 1036,1041 ****
|
|
Karsten Hopp |
828576 |
--- 1036,1049 ----
|
|
Karsten Hopp |
828576 |
ee('vim.current.xxx = True')
|
|
Karsten Hopp |
828576 |
EOF
|
|
Karsten Hopp |
828576 |
:"
|
|
Karsten Hopp |
828576 |
+ :" Test import TODO: BROKEN
|
|
Karsten Hopp |
828576 |
+ :"py3 << EOF
|
|
Karsten Hopp |
828576 |
+ :"vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\')
|
|
Karsten Hopp |
828576 |
+ :"from module import dir as d
|
|
Karsten Hopp |
828576 |
+ :"from modulex import ddir
|
|
Karsten Hopp |
828576 |
+ :"cb.append(d + ',' + ddir)
|
|
Karsten Hopp |
828576 |
+ :"EOF
|
|
Karsten Hopp |
828576 |
+ :"
|
|
Karsten Hopp |
828576 |
:" Test exceptions
|
|
Karsten Hopp |
828576 |
:fun Exe(e)
|
|
Karsten Hopp |
828576 |
: execute a:e
|
|
Karsten Hopp |
828576 |
*** ../vim-7.3.1162/src/auto/configure 2013-06-02 19:14:11.000000000 +0200
|
|
Karsten Hopp |
828576 |
--- src/auto/configure 2013-06-10 21:22:52.000000000 +0200
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 5289,5298 ****
|
|
Karsten Hopp |
828576 |
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_var_python_version" >&5
|
|
Karsten Hopp |
828576 |
$as_echo "$vi_cv_var_python_version" >&6; }
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python is 2.2 or better" >&5
|
|
Karsten Hopp |
828576 |
! $as_echo_n "checking Python is 2.2 or better... " >&6; }
|
|
Karsten Hopp |
828576 |
if ${vi_cv_path_python} -c \
|
|
Karsten Hopp |
828576 |
! "import sys; sys.exit(${vi_cv_var_python_version} < 2.2)"
|
|
Karsten Hopp |
828576 |
then
|
|
Karsten Hopp |
828576 |
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yep" >&5
|
|
Karsten Hopp |
828576 |
$as_echo "yep" >&6; }
|
|
Karsten Hopp |
828576 |
--- 5289,5298 ----
|
|
Karsten Hopp |
828576 |
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_var_python_version" >&5
|
|
Karsten Hopp |
828576 |
$as_echo "$vi_cv_var_python_version" >&6; }
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
! { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python is 2.3 or better" >&5
|
|
Karsten Hopp |
828576 |
! $as_echo_n "checking Python is 2.3 or better... " >&6; }
|
|
Karsten Hopp |
828576 |
if ${vi_cv_path_python} -c \
|
|
Karsten Hopp |
828576 |
! "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
|
|
Karsten Hopp |
828576 |
then
|
|
Karsten Hopp |
828576 |
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yep" >&5
|
|
Karsten Hopp |
828576 |
$as_echo "yep" >&6; }
|
|
Karsten Hopp |
828576 |
*** ../vim-7.3.1162/src/version.c 2013-06-10 20:47:33.000000000 +0200
|
|
Karsten Hopp |
828576 |
--- src/version.c 2013-06-10 20:53:23.000000000 +0200
|
|
Karsten Hopp |
828576 |
***************
|
|
Karsten Hopp |
828576 |
*** 730,731 ****
|
|
Karsten Hopp |
828576 |
--- 730,733 ----
|
|
Karsten Hopp |
828576 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
828576 |
+ /**/
|
|
Karsten Hopp |
828576 |
+ 1163,
|
|
Karsten Hopp |
828576 |
/**/
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
--
|
|
Karsten Hopp |
828576 |
The coffee just wasn't strong enough to defend itself -- Tom Waits
|
|
Karsten Hopp |
828576 |
|
|
Karsten Hopp |
828576 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
828576 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
828576 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
828576 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|