diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-11-28 17:04:43 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-11-28 17:04:43 +0100 |
commit | 9fee7d4729af19e7ce4950ede8de358c5eeb3772 (patch) | |
tree | 5122d7777963f3811c2a298ce56e372037b5424d /src/if_py_both.h | |
parent | e88a5f3a2c18426a68c4591d61bc612276878b46 (diff) | |
download | vim-git-9fee7d4729af19e7ce4950ede8de358c5eeb3772.tar.gz |
updated for version 7.4.107v7.4.107
Problem: Python: When vim.eval() encounters a Vim error, a try/catch in the
Python code doesn't catch it. (Yggdroot Chen)
Solution: Throw exceptions on errors in vim.eval(). (ZyX)
Diffstat (limited to 'src/if_py_both.h')
-rw-r--r-- | src/if_py_both.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/if_py_both.h b/src/if_py_both.h index e6db4a3d0..a8188c16f 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -566,6 +566,28 @@ VimTryEnd(void) PyErr_SetNone(PyExc_KeyboardInterrupt); return -1; } + else if (msg_list != NULL && *msg_list != NULL) + { + int should_free; + char_u *msg; + + msg = get_exception_string(*msg_list, ET_ERROR, NULL, &should_free); + + if (msg == NULL) + { + PyErr_NoMemory(); + return -1; + } + + PyErr_SetVim((char *) msg); + + free_global_msglist(); + + if (should_free) + vim_free(msg); + + return -1; + } else if (!did_throw) return (PyErr_Occurred() ? -1 : 0); /* Python exception is preferred over vim one; unlikely to occur though */ |