diff --git a/7.3.1000 b/7.3.1000 new file mode 100644 index 00000000..c9164fff --- /dev/null +++ b/7.3.1000 @@ -0,0 +1,55 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.1000 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.1000 (whoa!) +Problem: Typo in char value causes out of bounds access. +Solution: Fix character value. (Klemens Baum) +Files: src/regexp.c + + +*** ../vim-7.3.999/src/regexp.c 2013-05-21 00:02:54.000000000 +0200 +--- src/regexp.c 2013-05-21 21:25:58.000000000 +0200 +*************** +*** 6899,6905 **** + { + decomp_T d; + +! if (c >= 0x4b20 && c <= 0xfb4f) + { + d = decomp_table[c - 0xfb20]; + *c1 = d.a; +--- 6899,6905 ---- + { + decomp_T d; + +! if (c >= 0xfb20 && c <= 0xfb4f) + { + d = decomp_table[c - 0xfb20]; + *c1 = d.a; +*** ../vim-7.3.999/src/version.c 2013-05-21 21:20:16.000000000 +0200 +--- src/version.c 2013-05-21 21:22:14.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 1000, + /**/ + +-- +ARTHUR: The swallow may fly south with the sun, or the house martin or the + plover seek warmer hot lands in winter, yet these are not strangers to + our land. +SOLDIER: Are you suggesting coconuts migrate? + "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/7.3.988 b/7.3.988 new file mode 100644 index 00000000..46073b8c --- /dev/null +++ b/7.3.988 @@ -0,0 +1,50 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.988 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.988 +Problem: New regexp engine is slow. +Solution: Break out of the loop when the state list is empty. +Files: src/regexp_nfa.c + + +*** ../vim-7.3.987/src/regexp_nfa.c 2013-05-21 12:43:52.000000000 +0200 +--- src/regexp_nfa.c 2013-05-21 14:01:33.000000000 +0200 +*************** +*** 2951,2956 **** +--- 2951,2961 ---- + #ifdef NFA_REGEXP_DEBUG_LOG + fprintf(debug, "\n-------------------\n"); + #endif ++ /* ++ * If the state lists are empty we can stop. ++ */ ++ if (thislist->n == 0 && neglist->n == 0) ++ break; + + /* compute nextlist */ + for (i = 0; i < thislist->n || neglist->n > 0; ++i) +*** ../vim-7.3.987/src/version.c 2013-05-21 13:30:17.000000000 +0200 +--- src/version.c 2013-05-21 14:02:12.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 988, + /**/ + +-- +The chat program is in public domain. This is not the GNU public license. +If it breaks then you get to keep both pieces. + -- Copyright notice for the chat program + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/7.3.989 b/7.3.989 new file mode 100644 index 00000000..63103567 --- /dev/null +++ b/7.3.989 @@ -0,0 +1,67 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.989 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.989 +Problem: New regexp engine compares negative numbers to character. +Solution: Add missing case statements. +Files: src/regexp_nfa.c + + +*** ../vim-7.3.988/src/regexp_nfa.c 2013-05-21 14:02:55.000000000 +0200 +--- src/regexp_nfa.c 2013-05-21 15:31:47.000000000 +0200 +*************** +*** 3383,3390 **** +--- 3383,3412 ---- + ADD_POS_NEG_STATE(t->state); + break; + ++ case NFA_MOPEN + 0: ++ case NFA_MOPEN + 1: ++ case NFA_MOPEN + 2: ++ case NFA_MOPEN + 3: ++ case NFA_MOPEN + 4: ++ case NFA_MOPEN + 5: ++ case NFA_MOPEN + 6: ++ case NFA_MOPEN + 7: ++ case NFA_MOPEN + 8: ++ case NFA_MOPEN + 9: ++ /* handled below */ ++ break; ++ ++ case NFA_SKIP_CHAR: ++ case NFA_ZSTART: ++ /* TODO: should not happen? */ ++ break; ++ + default: /* regular character */ ++ /* TODO: put this in #ifdef later */ ++ if (t->state->c < -256) ++ EMSGN("INTERNAL: Negative state char: %ld", t->state->c); + result = (no_Magic(t->state->c) == c); ++ + if (!result) + result = ireg_ic == TRUE + && MB_TOLOWER(t->state->c) == MB_TOLOWER(c); +*** ../vim-7.3.988/src/version.c 2013-05-21 14:02:55.000000000 +0200 +--- src/version.c 2013-05-21 15:32:50.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 989, + /**/ + +-- +God made machine language; all the rest is the work of man. + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/7.3.990 b/7.3.990 new file mode 100644 index 00000000..aea9343f --- /dev/null +++ b/7.3.990 @@ -0,0 +1,305 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.990 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.990 +Problem: Memory leak in new regexp engine. +Solution: Jump to end of function to free memory. (Dominique Pelle) +Files: src/regexp_nfa.c + + +*** ../vim-7.3.989/src/regexp_nfa.c 2013-05-21 15:33:37.000000000 +0200 +--- src/regexp_nfa.c 2013-05-21 16:17:15.000000000 +0200 +*************** +*** 2143,2148 **** +--- 2143,2149 ---- + nfa_state_T *s; + nfa_state_T *s1; + nfa_state_T *matchstate; ++ nfa_state_T *ret = NULL; + + if (postfix == NULL) + return NULL; +*************** +*** 2211,2217 **** + e1 = POP(); + s = new_state(NFA_SPLIT, e1.start, e2.start); + if (s == NULL) +! return NULL; + PUSH(frag(s, append(e1.out, e2.out))); + break; + +--- 2212,2218 ---- + e1 = POP(); + s = new_state(NFA_SPLIT, e1.start, e2.start); + if (s == NULL) +! goto theend; + PUSH(frag(s, append(e1.out, e2.out))); + break; + +*************** +*** 2225,2231 **** + e = POP(); + s = new_state(NFA_SPLIT, e.start, NULL); + if (s == NULL) +! return NULL; + patch(e.out, s); + PUSH(frag(s, list1(&s->out1))); + break; +--- 2226,2232 ---- + e = POP(); + s = new_state(NFA_SPLIT, e.start, NULL); + if (s == NULL) +! goto theend; + patch(e.out, s); + PUSH(frag(s, list1(&s->out1))); + break; +*************** +*** 2240,2246 **** + e = POP(); + s = new_state(NFA_SPLIT, e.start, NULL); + if (s == NULL) +! return NULL; + PUSH(frag(s, append(e.out, list1(&s->out1)))); + break; + +--- 2241,2247 ---- + e = POP(); + s = new_state(NFA_SPLIT, e.start, NULL); + if (s == NULL) +! goto theend; + PUSH(frag(s, append(e.out, list1(&s->out1)))); + break; + +*************** +*** 2254,2260 **** + e = POP(); + s = new_state(NFA_SPLIT, NULL, e.start); + if (s == NULL) +! return NULL; + PUSH(frag(s, append(e.out, list1(&s->out)))); + break; + +--- 2255,2261 ---- + e = POP(); + s = new_state(NFA_SPLIT, NULL, e.start); + if (s == NULL) +! goto theend; + PUSH(frag(s, append(e.out, list1(&s->out)))); + break; + +*************** +*** 2268,2274 **** + e = POP(); + s = new_state(NFA_SPLIT, e.start, NULL); + if (s == NULL) +! return NULL; + patch(e.out, s); + PUSH(frag(e.start, list1(&s->out1))); + break; +--- 2269,2275 ---- + e = POP(); + s = new_state(NFA_SPLIT, e.start, NULL); + if (s == NULL) +! goto theend; + patch(e.out, s); + PUSH(frag(e.start, list1(&s->out1))); + break; +*************** +*** 2283,2289 **** + } + s = new_state(NFA_SKIP_CHAR, NULL, NULL); + if (s == NULL) +! return NULL; + PUSH(frag(s, list1(&s->out))); + break; + +--- 2284,2290 ---- + } + s = new_state(NFA_SKIP_CHAR, NULL, NULL); + if (s == NULL) +! goto theend; + PUSH(frag(s, list1(&s->out))); + break; + +*************** +*** 2293,2299 **** + * END_INVISIBLE, similarly to MOPEN. + */ + /* TODO: Maybe this drops the speed? */ +! return NULL; + + if (nfa_calc_size == TRUE) + { +--- 2294,2300 ---- + * END_INVISIBLE, similarly to MOPEN. + */ + /* TODO: Maybe this drops the speed? */ +! goto theend; + + if (nfa_calc_size == TRUE) + { +*************** +*** 2303,2314 **** + e = POP(); + s1 = new_state(NFA_END_INVISIBLE, NULL, NULL); + if (s1 == NULL) +! return NULL; + patch(e.out, s1); + + s = new_state(NFA_START_INVISIBLE, e.start, s1); + if (s == NULL) +! return NULL; + PUSH(frag(s, list1(&s1->out))); + break; + +--- 2304,2315 ---- + e = POP(); + s1 = new_state(NFA_END_INVISIBLE, NULL, NULL); + if (s1 == NULL) +! goto theend; + patch(e.out, s1); + + s = new_state(NFA_START_INVISIBLE, e.start, s1); + if (s == NULL) +! goto theend; + PUSH(frag(s, list1(&s1->out))); + break; + +*************** +*** 2357,2366 **** + { + s = new_state(mopen, NULL, NULL); + if (s == NULL) +! return NULL; + s1 = new_state(mclose, NULL, NULL); + if (s1 == NULL) +! return NULL; + patch(list1(&s->out), s1); + PUSH(frag(s, list1(&s1->out))); + break; +--- 2358,2367 ---- + { + s = new_state(mopen, NULL, NULL); + if (s == NULL) +! goto theend; + s1 = new_state(mclose, NULL, NULL); + if (s1 == NULL) +! goto theend; + patch(list1(&s->out), s1); + PUSH(frag(s, list1(&s1->out))); + break; +*************** +*** 2371,2381 **** + e = POP(); + s = new_state(mopen, e.start, NULL); /* `(' */ + if (s == NULL) +! return NULL; + + s1 = new_state(mclose, NULL, NULL); /* `)' */ + if (s1 == NULL) +! return NULL; + patch(e.out, s1); + + if (mopen == NFA_MULTIBYTE || mopen == NFA_COMPOSING) +--- 2372,2382 ---- + e = POP(); + s = new_state(mopen, e.start, NULL); /* `(' */ + if (s == NULL) +! goto theend; + + s1 = new_state(mclose, NULL, NULL); /* `)' */ + if (s1 == NULL) +! goto theend; + patch(e.out, s1); + + if (mopen == NFA_MULTIBYTE || mopen == NFA_COMPOSING) +*************** +*** 2397,2403 **** + } + s = new_state(*p, NULL, NULL); + if (s == NULL) +! return NULL; + PUSH(frag(s, list1(&s->out))); + break; + +--- 2398,2404 ---- + } + s = new_state(*p, NULL, NULL); + if (s == NULL) +! goto theend; + PUSH(frag(s, list1(&s->out))); + break; + +*************** +*** 2408,2414 **** + if (nfa_calc_size == TRUE) + { + nstate++; +! return NULL; /* Return value when counting size is ignored anyway */ + } + + e = POP(); +--- 2409,2415 ---- + if (nfa_calc_size == TRUE) + { + nstate++; +! goto theend; /* Return value when counting size is ignored anyway */ + } + + e = POP(); +*************** +*** 2418,2431 **** + if (istate >= nstate) + EMSG_RET_NULL(_("E876: (NFA regexp) Not enough space to store the whole NFA ")); + +- vim_free(stack); +- + matchstate = &state_ptr[istate++]; /* the match state */ + matchstate->c = NFA_MATCH; + matchstate->out = matchstate->out1 = NULL; + + patch(e.out, matchstate); +! return e.start; + + #undef POP1 + #undef PUSH1 +--- 2419,2434 ---- + if (istate >= nstate) + EMSG_RET_NULL(_("E876: (NFA regexp) Not enough space to store the whole NFA ")); + + matchstate = &state_ptr[istate++]; /* the match state */ + matchstate->c = NFA_MATCH; + matchstate->out = matchstate->out1 = NULL; + + patch(e.out, matchstate); +! ret = e.start; +! +! theend: +! vim_free(stack); +! return ret; + + #undef POP1 + #undef PUSH1 +*** ../vim-7.3.989/src/version.c 2013-05-21 15:33:37.000000000 +0200 +--- src/version.c 2013-05-21 16:18:03.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 990, + /**/ + +-- +This message contains 78% recycled characters. + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/7.3.991 b/7.3.991 new file mode 100644 index 00000000..3b28bcd9 --- /dev/null +++ b/7.3.991 @@ -0,0 +1,745 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.991 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.991 +Problem: More can be shared by Python 2 and 3. +Solution: Move more stuff to if_py_both. (ZyX) +Files: src/if_py_both.h, src/if_python3.c, src/if_python.c, + src/testdir/test87.ok + + +*** ../vim-7.3.990/src/if_py_both.h 2013-05-17 21:20:13.000000000 +0200 +--- src/if_py_both.h 2013-05-21 18:07:46.000000000 +0200 +*************** +*** 30,35 **** +--- 30,38 ---- + #define INVALID_WINDOW_VALUE ((win_T *)(-1)) + #define INVALID_TABPAGE_VALUE ((tabpage_T *)(-1)) + ++ typedef void (*rangeinitializer)(void *); ++ typedef void (*runner)(const char *, void *, PyGILState_STATE *); ++ + static int ConvertFromPyObject(PyObject *, typval_T *); + static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *); + static PyObject *WindowNew(win_T *, tabpage_T *); +*************** +*** 39,44 **** +--- 42,49 ---- + static PyInt RangeStart; + static PyInt RangeEnd; + ++ static PyObject *globals; ++ + /* + * obtain a lock on the Vim data structures + */ +*************** +*** 1296,1302 **** + FunctionObject *this = (FunctionObject *) (self); + + func_unref(this->name); +! PyMem_Del(this->name); + + DESTRUCTOR_FINISH(self); + } +--- 1301,1307 ---- + FunctionObject *this = (FunctionObject *) (self); + + func_unref(this->name); +! PyMem_Free(this->name); + + DESTRUCTOR_FINISH(self); + } +*************** +*** 3432,3437 **** +--- 3437,3562 ---- + } + + static void ++ init_range_cmd(exarg_T *eap) ++ { ++ RangeStart = eap->line1; ++ RangeEnd = eap->line2; ++ } ++ ++ static void ++ init_range_eval(typval_T *rettv UNUSED) ++ { ++ RangeStart = (PyInt) curwin->w_cursor.lnum; ++ RangeEnd = RangeStart; ++ } ++ ++ static void ++ run_cmd(const char *cmd, void *arg UNUSED, PyGILState_STATE *pygilstate UNUSED) ++ { ++ PyRun_SimpleString((char *) cmd); ++ } ++ ++ static const char *code_hdr = "def " DOPY_FUNC "(line, linenr):\n "; ++ static int code_hdr_len = 30; ++ ++ static void ++ run_do(const char *cmd, void *arg UNUSED, PyGILState_STATE *pygilstate) ++ { ++ PyInt lnum; ++ size_t len; ++ char *code; ++ int status; ++ PyObject *pyfunc, *pymain; ++ ++ if (u_save(RangeStart - 1, RangeEnd + 1) != OK) ++ { ++ EMSG(_("cannot save undo information")); ++ return; ++ } ++ ++ len = code_hdr_len + STRLEN(cmd); ++ code = PyMem_New(char, len + 1); ++ memcpy(code, code_hdr, code_hdr_len); ++ STRCPY(code + code_hdr_len, cmd); ++ status = PyRun_SimpleString(code); ++ PyMem_Free(code); ++ ++ if (status) ++ { ++ EMSG(_("failed to run the code")); ++ return; ++ } ++ ++ status = 0; ++ pymain = PyImport_AddModule("__main__"); ++ pyfunc = PyObject_GetAttrString(pymain, DOPY_FUNC); ++ PyGILState_Release(*pygilstate); ++ ++ for (lnum = RangeStart; lnum <= RangeEnd; ++lnum) ++ { ++ PyObject *line, *linenr, *ret; ++ ++ *pygilstate = PyGILState_Ensure(); ++ if (!(line = GetBufferLine(curbuf, lnum))) ++ goto err; ++ if (!(linenr = PyInt_FromLong((long) lnum))) ++ { ++ Py_DECREF(line); ++ goto err; ++ } ++ ret = PyObject_CallFunctionObjArgs(pyfunc, line, linenr, NULL); ++ Py_DECREF(line); ++ Py_DECREF(linenr); ++ if (!ret) ++ goto err; ++ ++ if (ret != Py_None) ++ if (SetBufferLine(curbuf, lnum, ret, NULL) == FAIL) ++ goto err; ++ ++ Py_XDECREF(ret); ++ PythonIO_Flush(); ++ PyGILState_Release(*pygilstate); ++ } ++ goto out; ++ err: ++ *pygilstate = PyGILState_Ensure(); ++ PyErr_PrintEx(0); ++ PythonIO_Flush(); ++ status = 1; ++ out: ++ if (!status) ++ *pygilstate = PyGILState_Ensure(); ++ Py_DECREF(pyfunc); ++ PyObject_SetAttrString(pymain, DOPY_FUNC, NULL); ++ if (status) ++ return; ++ check_cursor(); ++ update_curbuf(NOT_VALID); ++ } ++ ++ static void ++ run_eval(const char *cmd, typval_T *rettv, PyGILState_STATE *pygilstate UNUSED) ++ { ++ PyObject *r; ++ ++ r = PyRun_String((char *) cmd, Py_eval_input, globals, globals); ++ if (r == NULL) ++ { ++ if (PyErr_Occurred() && !msg_silent) ++ PyErr_PrintEx(0); ++ EMSG(_("E858: Eval did not return a valid python object")); ++ } ++ else ++ { ++ if (ConvertFromPyObject(r, rettv) == -1) ++ EMSG(_("E859: Failed to convert returned python object to vim value")); ++ Py_DECREF(r); ++ } ++ PyErr_Clear(); ++ } ++ ++ static void + set_ref_in_py(const int copyID) + { + pylinkedlist_T *cur; +*** ../vim-7.3.990/src/if_python3.c 2013-05-17 16:39:59.000000000 +0200 +--- src/if_python3.c 2013-05-21 18:07:39.000000000 +0200 +*************** +*** 703,710 **** + * Internal function prototypes. + */ + +- static PyObject *globals; +- + static int PythonIO_Init(void); + static PyObject *Py3Init_vim(void); + +--- 703,708 ---- +*************** +*** 827,833 **** + * External interface + */ + static void +! DoPy3Command(exarg_T *eap, const char *cmd, typval_T *rettv) + { + #if defined(MACOS) && !defined(MACOS_X_UNIX) + GrafPtr oldPort; +--- 825,831 ---- + * External interface + */ + static void +! DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) + { + #if defined(MACOS) && !defined(MACOS_X_UNIX) + GrafPtr oldPort; +*************** +*** 848,863 **** + if (Python3_Init()) + goto theend; + +! if (rettv == NULL) +! { +! RangeStart = eap->line1; +! RangeEnd = eap->line2; +! } +! else +! { +! RangeStart = (PyInt) curwin->w_cursor.lnum; +! RangeEnd = RangeStart; +! } + Python_Release_Vim(); /* leave vim */ + + #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) +--- 846,853 ---- + if (Python3_Init()) + goto theend; + +! init_range(arg); +! + Python_Release_Vim(); /* leave vim */ + + #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) +*************** +*** 881,908 **** + (char *)ENC_OPT, CODEC_ERROR_HANDLER); + cmdbytes = PyUnicode_AsEncodedString(cmdstr, "utf-8", CODEC_ERROR_HANDLER); + Py_XDECREF(cmdstr); +- if (rettv == NULL) +- PyRun_SimpleString(PyBytes_AsString(cmdbytes)); +- else +- { +- PyObject *r; + +! r = PyRun_String(PyBytes_AsString(cmdbytes), Py_eval_input, +! globals, globals); +! if (r == NULL) +! { +! if (PyErr_Occurred() && !msg_silent) +! PyErr_PrintEx(0); +! EMSG(_("E860: Eval did not return a valid python 3 object")); +! } +! else +! { +! if (ConvertFromPyObject(r, rettv) == -1) +! EMSG(_("E861: Failed to convert returned python 3 object to vim value")); +! Py_DECREF(r); +! } +! PyErr_Clear(); +! } + Py_XDECREF(cmdbytes); + + PyGILState_Release(pygilstate); +--- 871,878 ---- + (char *)ENC_OPT, CODEC_ERROR_HANDLER); + cmdbytes = PyUnicode_AsEncodedString(cmdstr, "utf-8", CODEC_ERROR_HANDLER); + Py_XDECREF(cmdstr); + +! run(PyBytes_AsString(cmdbytes), arg, &pygilstate); + Py_XDECREF(cmdbytes); + + PyGILState_Release(pygilstate); +*************** +*** 936,945 **** + script = script_get(eap, eap->arg); + if (!eap->skip) + { +! if (script == NULL) +! DoPy3Command(eap, (char *)eap->arg, NULL); +! else +! DoPy3Command(eap, (char *)script, NULL); + } + vim_free(script); + } +--- 906,915 ---- + script = script_get(eap, eap->arg); + if (!eap->skip) + { +! DoPyCommand(script == NULL ? (char *) eap->arg : (char *) script, +! (rangeinitializer) init_range_cmd, +! (runner) run_cmd, +! (void *) eap); + } + vim_free(script); + } +*************** +*** 1000,1100 **** + + + /* Execute the file */ +! DoPy3Command(eap, buffer, NULL); + } + + void + ex_py3do(exarg_T *eap) + { +! linenr_T i; +! const char *code_hdr = "def " DOPY_FUNC "(line, linenr):\n "; +! const char *s = (const char *) eap->arg; +! size_t len; +! char *code; +! int status; +! PyObject *pyfunc, *pymain; +! PyGILState_STATE pygilstate; +! +! if (Python3_Init()) +! goto theend; +! +! if (u_save(eap->line1 - 1, eap->line2 + 1) != OK) +! { +! EMSG(_("cannot save undo information")); +! return; +! } +! len = strlen(code_hdr) + strlen(s); +! code = malloc(len + 1); +! STRCPY(code, code_hdr); +! STRNCAT(code, s, len + 1); +! pygilstate = PyGILState_Ensure(); +! status = PyRun_SimpleString(code); +! vim_free(code); +! if (status) +! { +! EMSG(_("failed to run the code")); +! return; +! } +! status = 0; /* good */ +! pymain = PyImport_AddModule("__main__"); +! pyfunc = PyObject_GetAttrString(pymain, DOPY_FUNC); +! PyGILState_Release(pygilstate); +! +! for (i = eap->line1; i <= eap->line2; i++) +! { +! const char *line; +! PyObject *pyline, *pylinenr, *pyret, *pybytes; +! +! line = (char *)ml_get(i); +! pygilstate = PyGILState_Ensure(); +! pyline = PyUnicode_Decode(line, strlen(line), +! (char *)ENC_OPT, CODEC_ERROR_HANDLER); +! pylinenr = PyLong_FromLong(i); +! pyret = PyObject_CallFunctionObjArgs(pyfunc, pyline, pylinenr, NULL); +! Py_DECREF(pyline); +! Py_DECREF(pylinenr); +! if (!pyret) +! { +! PyErr_PrintEx(0); +! PythonIO_Flush(); +! status = 1; +! goto out; +! } +! +! if (pyret && pyret != Py_None) +! { +! if (!PyUnicode_Check(pyret)) +! { +! EMSG(_("E863: return value must be an instance of str")); +! Py_XDECREF(pyret); +! status = 1; +! goto out; +! } +! pybytes = PyUnicode_AsEncodedString(pyret, +! (char *)ENC_OPT, CODEC_ERROR_HANDLER); +! ml_replace(i, (char_u *) PyBytes_AsString(pybytes), 1); +! Py_DECREF(pybytes); +! changed(); +! #ifdef SYNTAX_HL +! syn_changed(i); /* recompute syntax hl. for this line */ +! #endif +! } +! Py_XDECREF(pyret); +! PythonIO_Flush(); +! PyGILState_Release(pygilstate); +! } +! pygilstate = PyGILState_Ensure(); +! out: +! Py_DECREF(pyfunc); +! PyObject_SetAttrString(pymain, DOPY_FUNC, NULL); +! PyGILState_Release(pygilstate); +! if (status) +! return; +! check_cursor(); +! update_curbuf(NOT_VALID); +! +! theend: +! return; + } + + /****************************************************** +--- 970,988 ---- + + + /* Execute the file */ +! DoPyCommand(buffer, +! (rangeinitializer) init_range_cmd, +! (runner) run_cmd, +! (void *) eap); + } + + void + ex_py3do(exarg_T *eap) + { +! DoPyCommand((char *)eap->arg, +! (rangeinitializer)init_range_cmd, +! (runner)run_do, +! (void *)eap); + } + + /****************************************************** +*************** +*** 1790,1796 **** + void + do_py3eval (char_u *str, typval_T *rettv) + { +! DoPy3Command(NULL, (char *) str, rettv); + switch(rettv->v_type) + { + case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break; +--- 1678,1687 ---- + void + do_py3eval (char_u *str, typval_T *rettv) + { +! DoPyCommand((char *) str, +! (rangeinitializer) init_range_eval, +! (runner) run_eval, +! (void *) rettv); + switch(rettv->v_type) + { + case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break; +*** ../vim-7.3.990/src/if_python.c 2013-05-17 16:39:59.000000000 +0200 +--- src/if_python.c 2013-05-21 18:07:11.000000000 +0200 +*************** +*** 659,666 **** + * Internal function prototypes. + */ + +- static PyObject *globals; +- + static void PythonIO_Flush(void); + static int PythonIO_Init(void); + static int PythonMod_Init(void); +--- 659,664 ---- +*************** +*** 828,834 **** + * External interface + */ + static void +! DoPythonCommand(exarg_T *eap, const char *cmd, typval_T *rettv) + { + #ifndef PY_CAN_RECURSE + static int recursive = 0; +--- 826,832 ---- + * External interface + */ + static void +! DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) + { + #ifndef PY_CAN_RECURSE + static int recursive = 0; +*************** +*** 861,876 **** + if (Python_Init()) + goto theend; + +! if (rettv == NULL) +! { +! RangeStart = eap->line1; +! RangeEnd = eap->line2; +! } +! else +! { +! RangeStart = (PyInt) curwin->w_cursor.lnum; +! RangeEnd = RangeStart; +! } + Python_Release_Vim(); /* leave vim */ + + #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) +--- 859,866 ---- + if (Python_Init()) + goto theend; + +! init_range(arg); +! + Python_Release_Vim(); /* leave vim */ + + #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) +*************** +*** 892,918 **** + Python_RestoreThread(); /* enter python */ + #endif + +! if (rettv == NULL) +! PyRun_SimpleString((char *)(cmd)); +! else +! { +! PyObject *r; +! +! r = PyRun_String((char *)(cmd), Py_eval_input, globals, globals); +! if (r == NULL) +! { +! if (PyErr_Occurred() && !msg_silent) +! PyErr_PrintEx(0); +! EMSG(_("E858: Eval did not return a valid python object")); +! } +! else +! { +! if (ConvertFromPyObject(r, rettv) == -1) +! EMSG(_("E859: Failed to convert returned python object to vim value")); +! Py_DECREF(r); +! } +! PyErr_Clear(); +! } + + #ifdef PY_CAN_RECURSE + PyGILState_Release(pygilstate); +--- 882,888 ---- + Python_RestoreThread(); /* enter python */ + #endif + +! run((char *) cmd, arg, &pygilstate); + + #ifdef PY_CAN_RECURSE + PyGILState_Release(pygilstate); +*************** +*** 952,961 **** + script = script_get(eap, eap->arg); + if (!eap->skip) + { +! if (script == NULL) +! DoPythonCommand(eap, (char *)eap->arg, NULL); +! else +! DoPythonCommand(eap, (char *)script, NULL); + } + vim_free(script); + } +--- 922,931 ---- + script = script_get(eap, eap->arg); + if (!eap->skip) + { +! DoPyCommand(script == NULL ? (char *) eap->arg : (char *) script, +! (rangeinitializer) init_range_cmd, +! (runner) run_cmd, +! (void *) eap); + } + vim_free(script); + } +*************** +*** 1001,1094 **** + *p++ = '\0'; + + /* Execute the file */ +! DoPythonCommand(eap, buffer, NULL); + } + + void + ex_pydo(exarg_T *eap) + { +! linenr_T i; +! const char *code_hdr = "def " DOPY_FUNC "(line, linenr):\n "; +! const char *s = (const char *) eap->arg; +! size_t len; +! char *code; +! int status; +! PyObject *pyfunc, *pymain; +! PyGILState_STATE pygilstate; +! +! if (Python_Init()) +! return; +! +! if (u_save(eap->line1 - 1, eap->line2 + 1) != OK) +! { +! EMSG(_("cannot save undo information")); +! return; +! } +! len = strlen(code_hdr) + strlen(s); +! code = malloc(len + 1); +! STRCPY(code, code_hdr); +! STRNCAT(code, s, len + 1); +! pygilstate = PyGILState_Ensure(); +! status = PyRun_SimpleString(code); +! vim_free(code); +! if (status) +! { +! EMSG(_("failed to run the code")); +! return; +! } +! status = 0; /* good */ +! pymain = PyImport_AddModule("__main__"); +! pyfunc = PyObject_GetAttrString(pymain, DOPY_FUNC); +! PyGILState_Release(pygilstate); +! +! for (i = eap->line1; i <= eap->line2; i++) +! { +! const char *line; +! PyObject *pyline, *pylinenr, *pyret; +! +! line = (char *)ml_get(i); +! pygilstate = PyGILState_Ensure(); +! pyline = PyString_FromStringAndSize(line, strlen(line)); +! pylinenr = PyLong_FromLong(i); +! pyret = PyObject_CallFunctionObjArgs(pyfunc, pyline, pylinenr, NULL); +! Py_DECREF(pyline); +! Py_DECREF(pylinenr); +! if (!pyret) +! { +! PyErr_PrintEx(0); +! PythonIO_Flush(); +! status = 1; +! goto out; +! } +! +! if (pyret && pyret != Py_None) +! { +! if (!PyString_Check(pyret)) +! { +! EMSG(_("E863: return value must be an instance of str")); +! Py_XDECREF(pyret); +! status = 1; +! goto out; +! } +! ml_replace(i, (char_u *) PyString_AsString(pyret), 1); +! changed(); +! #ifdef SYNTAX_HL +! syn_changed(i); /* recompute syntax hl. for this line */ +! #endif +! } +! Py_XDECREF(pyret); +! PythonIO_Flush(); +! PyGILState_Release(pygilstate); +! } +! pygilstate = PyGILState_Ensure(); +! out: +! Py_DECREF(pyfunc); +! PyObject_SetAttrString(pymain, DOPY_FUNC, NULL); +! PyGILState_Release(pygilstate); +! if (status) +! return; +! check_cursor(); +! update_curbuf(NOT_VALID); + } + + /****************************************************** +--- 971,989 ---- + *p++ = '\0'; + + /* Execute the file */ +! DoPyCommand(buffer, +! (rangeinitializer) init_range_cmd, +! (runner) run_cmd, +! (void *) eap); + } + + void + ex_pydo(exarg_T *eap) + { +! DoPyCommand((char *)eap->arg, +! (rangeinitializer) init_range_cmd, +! (runner)run_do, +! (void *)eap); + } + + /****************************************************** +*************** +*** 1525,1531 **** + void + do_pyeval (char_u *str, typval_T *rettv) + { +! DoPythonCommand(NULL, (char *) str, rettv); + switch(rettv->v_type) + { + case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break; +--- 1420,1429 ---- + void + do_pyeval (char_u *str, typval_T *rettv) + { +! DoPyCommand((char *) str, +! (rangeinitializer) init_range_eval, +! (runner) run_eval, +! (void *) rettv); + switch(rettv->v_type) + { + case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break; +*** ../vim-7.3.990/src/testdir/test87.ok 2013-05-17 16:18:27.000000000 +0200 +--- src/testdir/test87.ok 2013-05-21 17:59:56.000000000 +0200 +*************** +*** 59,68 **** + ['c', 1] + ['d', ['e']] + 0.0 +! "\0": Vim(let):E861: +! {"\0": 1}: Vim(let):E861: + undefined_name: Vim(let):Trace +! vim: Vim(let):E861: + [1] + [1, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 1] + Abc +--- 59,68 ---- + ['c', 1] + ['d', ['e']] + 0.0 +! "\0": Vim(let):E859: +! {"\0": 1}: Vim(let):E859: + undefined_name: Vim(let):Trace +! vim: Vim(let):E859: + [1] + [1, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 1] + Abc +*** ../vim-7.3.990/src/version.c 2013-05-21 16:28:05.000000000 +0200 +--- src/version.c 2013-05-21 18:19:20.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 991, + /**/ + +-- +Mynd you, m00se bites Kan be pretty nasti ... + "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/7.3.992 b/7.3.992 new file mode 100644 index 00000000..f3f233bb --- /dev/null +++ b/7.3.992 @@ -0,0 +1,2719 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.992 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.992 +Problem: Python: Too many type casts. +Solution: Change argument types. (ZyX) +Files: src/if_py_both.h, src/if_python3.c, src/if_python.c + + +*** ../vim-7.3.991/src/if_py_both.h 2013-05-21 18:19:33.000000000 +0200 +--- src/if_py_both.h 2013-05-21 18:22:03.000000000 +0200 +*************** +*** 76,82 **** + } OutputObject; + + static int +! OutputSetattr(PyObject *self, char *name, PyObject *val) + { + if (val == NULL) + { +--- 76,82 ---- + } OutputObject; + + static int +! OutputSetattr(OutputObject *self, char *name, PyObject *val) + { + if (val == NULL) + { +*************** +*** 93,99 **** + return -1; + } + +! ((OutputObject *)(self))->softspace = PyInt_AsLong(val); + return 0; + } + +--- 93,99 ---- + return -1; + } + +! self->softspace = PyInt_AsLong(val); + return 0; + } + +*************** +*** 152,162 **** + } + + static PyObject * +! OutputWrite(PyObject *self, PyObject *args) + { + Py_ssize_t len = 0; + char *str = NULL; +! int error = ((OutputObject *)(self))->error; + + if (!PyArg_ParseTuple(args, "et#", ENC_OPT, &str, &len)) + return NULL; +--- 152,162 ---- + } + + static PyObject * +! OutputWrite(OutputObject *self, PyObject *args) + { + Py_ssize_t len = 0; + char *str = NULL; +! int error = self->error; + + if (!PyArg_ParseTuple(args, "et#", ENC_OPT, &str, &len)) + return NULL; +*************** +*** 173,184 **** + } + + static PyObject * +! OutputWritelines(PyObject *self, PyObject *args) + { + PyInt n; + PyInt i; + PyObject *list; +! int error = ((OutputObject *)(self))->error; + + if (!PyArg_ParseTuple(args, "O", &list)) + return NULL; +--- 173,184 ---- + } + + static PyObject * +! OutputWritelines(OutputObject *self, PyObject *args) + { + PyInt n; + PyInt i; + PyObject *list; +! int error = self->error; + + if (!PyArg_ParseTuple(args, "O", &list)) + return NULL; +*************** +*** 220,226 **** + } + + static PyObject * +! OutputFlush(PyObject *self UNUSED, PyObject *args UNUSED) + { + /* do nothing */ + Py_INCREF(Py_None); +--- 220,226 ---- + } + + static PyObject * +! OutputFlush(PyObject *self UNUSED) + { + /* do nothing */ + Py_INCREF(Py_None); +*************** +*** 230,240 **** + /***************/ + + static struct PyMethodDef OutputMethods[] = { +! /* name, function, calling, documentation */ +! {"write", OutputWrite, 1, ""}, +! {"writelines", OutputWritelines, 1, ""}, +! {"flush", OutputFlush, 1, ""}, +! { NULL, NULL, 0, NULL} + }; + + static OutputObject Output = +--- 230,240 ---- + /***************/ + + static struct PyMethodDef OutputMethods[] = { +! /* name, function, calling, doc */ +! {"write", (PyCFunction)OutputWrite, METH_VARARGS, ""}, +! {"writelines", (PyCFunction)OutputWritelines, METH_VARARGS, ""}, +! {"flush", (PyCFunction)OutputFlush, METH_NOARGS, ""}, +! { NULL, NULL, 0, NULL} + }; + + static OutputObject Output = +*************** +*** 533,544 **** + */ + + static struct PyMethodDef VimMethods[] = { +! /* name, function, calling, documentation */ +! {"command", VimCommand, 1, "Execute a Vim ex-mode command" }, +! {"eval", VimEval, 1, "Evaluate an expression using Vim evaluator" }, +! {"bindeval", VimEvalPy, 1, "Like eval(), but returns objects attached to vim ones"}, +! {"strwidth", VimStrwidth, 1, "Screen string width, counts as having width 1"}, +! { NULL, NULL, 0, NULL } + }; + + /* +--- 533,544 ---- + */ + + static struct PyMethodDef VimMethods[] = { +! /* name, function, calling, documentation */ +! {"command", VimCommand, METH_VARARGS, "Execute a Vim ex-mode command" }, +! {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" }, +! {"bindeval", VimEvalPy, METH_VARARGS, "Like eval(), but returns objects attached to vim ones"}, +! {"strwidth", VimStrwidth, METH_VARARGS, "Screen string width, counts as having width 1"}, +! { NULL, NULL, 0, NULL } + }; + + /* +*************** +*** 583,604 **** + } + + static void +! IterDestructor(PyObject *self) + { +! IterObject *this = (IterObject *)(self); +! +! this->destruct(this->cur); + + DESTRUCTOR_FINISH(self); + } + + static int +! IterTraverse(PyObject *self, visitproc visit, void *arg) + { +! IterObject *this = (IterObject *)(self); +! +! if (this->traverse != NULL) +! return this->traverse(this->cur, visit, arg); + else + return 0; + } +--- 583,600 ---- + } + + static void +! IterDestructor(IterObject *self) + { +! self->destruct(self->cur); + + DESTRUCTOR_FINISH(self); + } + + static int +! IterTraverse(IterObject *self, visitproc visit, void *arg) + { +! if (self->traverse != NULL) +! return self->traverse(self->cur, visit, arg); + else + return 0; + } +*************** +*** 609,630 **** + #endif + + static int +! IterClear(PyObject *self) + { +! IterObject *this = (IterObject *)(self); +! +! if (this->clear != NULL) +! return this->clear(&this->cur); + else + return 0; + } + + static PyObject * +! IterNext(PyObject *self) + { +! IterObject *this = (IterObject *)(self); +! +! return this->next(&this->cur); + } + + static PyObject * +--- 605,622 ---- + #endif + + static int +! IterClear(IterObject *self) + { +! if (self->clear != NULL) +! return self->clear(&self->cur); + else + return 0; + } + + static PyObject * +! IterNext(IterObject *self) + { +! return self->next(&self->cur); + } + + static PyObject * +*************** +*** 711,731 **** + } + + static void +! DictionaryDestructor(PyObject *self) + { +! DictionaryObject *this = ((DictionaryObject *) (self)); +! +! pyll_remove(&this->ref, &lastdict); +! dict_unref(this->dict); + + DESTRUCTOR_FINISH(self); + } + + static int +! DictionarySetattr(PyObject *self, char *name, PyObject *val) + { +- DictionaryObject *this = (DictionaryObject *)(self); +- + if (val == NULL) + { + PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes")); +--- 703,719 ---- + } + + static void +! DictionaryDestructor(DictionaryObject *self) + { +! pyll_remove(&self->ref, &lastdict); +! dict_unref(self->dict); + + DESTRUCTOR_FINISH(self); + } + + static int +! DictionarySetattr(DictionaryObject *self, char *name, PyObject *val) + { + if (val == NULL) + { + PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes")); +*************** +*** 734,740 **** + + if (strcmp(name, "locked") == 0) + { +! if (this->dict->dv_lock == VAR_FIXED) + { + PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed dictionary")); + return -1; +--- 722,728 ---- + + if (strcmp(name, "locked") == 0) + { +! if (self->dict->dv_lock == VAR_FIXED) + { + PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed dictionary")); + return -1; +*************** +*** 745,753 **** + if (istrue == -1) + return -1; + else if (istrue) +! this->dict->dv_lock = VAR_LOCKED; + else +! this->dict->dv_lock = 0; + } + return 0; + } +--- 733,741 ---- + if (istrue == -1) + return -1; + else if (istrue) +! self->dict->dv_lock = VAR_LOCKED; + else +! self->dict->dv_lock = 0; + } + return 0; + } +*************** +*** 759,771 **** + } + + static PyInt +! DictionaryLength(PyObject *self) + { +! return ((PyInt) ((((DictionaryObject *)(self))->dict->dv_hashtab.ht_used))); + } + + static PyObject * +! DictionaryItem(PyObject *self, PyObject *keyObject) + { + char_u *key; + dictitem_T *di; +--- 747,759 ---- + } + + static PyInt +! DictionaryLength(DictionaryObject *self) + { +! return ((PyInt) (self->dict->dv_hashtab.ht_used)); + } + + static PyObject * +! DictionaryItem(DictionaryObject *self, PyObject *keyObject) + { + char_u *key; + dictitem_T *di; +*************** +*** 773,779 **** + + DICTKEY_GET_NOTEMPTY(NULL) + +! di = dict_find(((DictionaryObject *) (self))->dict, key, -1); + + DICTKEY_UNREF + +--- 761,767 ---- + + DICTKEY_GET_NOTEMPTY(NULL) + +! di = dict_find(self->dict, key, -1); + + DICTKEY_UNREF + +*************** +*** 787,797 **** + } + + static PyInt +! DictionaryAssItem(PyObject *self, PyObject *keyObject, PyObject *valObject) + { + char_u *key; + typval_T tv; +! dict_T *d = ((DictionaryObject *)(self))->dict; + dictitem_T *di; + DICTKEY_DECL + +--- 775,785 ---- + } + + static PyInt +! DictionaryAssItem(DictionaryObject *self, PyObject *keyObject, PyObject *valObject) + { + char_u *key; + typval_T tv; +! dict_T *d = self->dict; + dictitem_T *di; + DICTKEY_DECL + +*************** +*** 852,860 **** + } + + static PyObject * +! DictionaryListKeys(PyObject *self UNUSED) + { +! dict_T *dict = ((DictionaryObject *)(self))->dict; + long_u todo = dict->dv_hashtab.ht_used; + Py_ssize_t i = 0; + PyObject *r; +--- 840,848 ---- + } + + static PyObject * +! DictionaryListKeys(DictionaryObject *self) + { +! dict_T *dict = self->dict; + long_u todo = dict->dv_hashtab.ht_used; + Py_ssize_t i = 0; + PyObject *r; +*************** +*** 880,887 **** + }; + + static struct PyMethodDef DictionaryMethods[] = { +! {"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""}, +! { NULL, NULL, 0, NULL } + }; + + static PyTypeObject ListType; +--- 868,875 ---- + }; + + static struct PyMethodDef DictionaryMethods[] = { +! {"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""}, +! { NULL, NULL, 0, NULL } + }; + + static PyTypeObject ListType; +*************** +*** 912,923 **** + } + + static void +! ListDestructor(PyObject *self) + { +! ListObject *this = (ListObject *)(self); +! +! pyll_remove(&this->ref, &lastlist); +! list_unref(this->list); + + DESTRUCTOR_FINISH(self); + } +--- 900,909 ---- + } + + static void +! ListDestructor(ListObject *self) + { +! pyll_remove(&self->ref, &lastlist); +! list_unref(self->list); + + DESTRUCTOR_FINISH(self); + } +*************** +*** 952,973 **** + } + + static PyInt +! ListLength(PyObject *self) + { +! return ((PyInt) (((ListObject *) (self))->list->lv_len)); + } + + static PyObject * +! ListItem(PyObject *self, Py_ssize_t index) + { + listitem_T *li; + +! if (index>=ListLength(self)) + { + PyErr_SetString(PyExc_IndexError, _("list index out of range")); + return NULL; + } +! li = list_find(((ListObject *) (self))->list, (long) index); + if (li == NULL) + { + PyErr_SetVim(_("internal error: failed to get vim list item")); +--- 938,959 ---- + } + + static PyInt +! ListLength(ListObject *self) + { +! return ((PyInt) (self->list->lv_len)); + } + + static PyObject * +! ListItem(ListObject *self, Py_ssize_t index) + { + listitem_T *li; + +! if (index >= ListLength(self)) + { + PyErr_SetString(PyExc_IndexError, _("list index out of range")); + return NULL; + } +! li = list_find(self->list, (long) index); + if (li == NULL) + { + PyErr_SetVim(_("internal error: failed to get vim list item")); +*************** +*** 991,997 **** + last = size; + + static PyObject * +! ListSlice(PyObject *self, Py_ssize_t first, Py_ssize_t last) + { + PyInt i; + PyInt size = ListLength(self); +--- 977,983 ---- + last = size; + + static PyObject * +! ListSlice(ListObject *self, Py_ssize_t first, Py_ssize_t last) + { + PyInt i; + PyInt size = ListLength(self); +*************** +*** 1058,1067 **** + } + + static PyObject * +! ListIter(PyObject *self) + { + listiterinfo_T *lii; +! list_T *l = ((ListObject *) (self))->list; + + if (!(lii = PyMem_New(listiterinfo_T, 1))) + { +--- 1044,1053 ---- + } + + static PyObject * +! ListIter(ListObject *self) + { + listiterinfo_T *lii; +! list_T *l = self->list; + + if (!(lii = PyMem_New(listiterinfo_T, 1))) + { +*************** +*** 1079,1088 **** + } + + static int +! ListAssItem(PyObject *self, Py_ssize_t index, PyObject *obj) + { + typval_T tv; +! list_T *l = ((ListObject *) (self))->list; + listitem_T *li; + Py_ssize_t length = ListLength(self); + +--- 1065,1074 ---- + } + + static int +! ListAssItem(ListObject *self, Py_ssize_t index, PyObject *obj) + { + typval_T tv; +! list_T *l = self->list; + listitem_T *li; + Py_ssize_t length = ListLength(self); + +*************** +*** 1127,1133 **** + } + + static int +! ListAssSlice(PyObject *self, Py_ssize_t first, Py_ssize_t last, PyObject *obj) + { + PyInt size = ListLength(self); + Py_ssize_t i; +--- 1113,1119 ---- + } + + static int +! ListAssSlice(ListObject *self, Py_ssize_t first, Py_ssize_t last, PyObject *obj) + { + PyInt size = ListLength(self); + Py_ssize_t i; +*************** +*** 1136,1142 **** + listitem_T *li; + listitem_T *next; + typval_T v; +! list_T *l = ((ListObject *) (self))->list; + + if (l->lv_lock) + { +--- 1122,1128 ---- + listitem_T *li; + listitem_T *next; + typval_T v; +! list_T *l = self->list; + + if (l->lv_lock) + { +*************** +*** 1196,1204 **** + } + + static PyObject * +! ListConcatInPlace(PyObject *self, PyObject *obj) + { +! list_T *l = ((ListObject *) (self))->list; + PyObject *lookup_dict; + + if (l->lv_lock) +--- 1182,1190 ---- + } + + static PyObject * +! ListConcatInPlace(ListObject *self, PyObject *obj) + { +! list_T *l = self->list; + PyObject *lookup_dict; + + if (l->lv_lock) +*************** +*** 1222,1235 **** + Py_DECREF(lookup_dict); + + Py_INCREF(self); +! return self; + } + + static int +! ListSetattr(PyObject *self, char *name, PyObject *val) + { +- ListObject *this = (ListObject *)(self); +- + if (val == NULL) + { + PyErr_SetString(PyExc_AttributeError, +--- 1208,1219 ---- + Py_DECREF(lookup_dict); + + Py_INCREF(self); +! return (PyObject *)(self); + } + + static int +! ListSetattr(ListObject *self, char *name, PyObject *val) + { + if (val == NULL) + { + PyErr_SetString(PyExc_AttributeError, +*************** +*** 1239,1245 **** + + if (strcmp(name, "locked") == 0) + { +! if (this->list->lv_lock == VAR_FIXED) + { + PyErr_SetString(PyExc_TypeError, _("cannot modify fixed list")); + return -1; +--- 1223,1229 ---- + + if (strcmp(name, "locked") == 0) + { +! if (self->list->lv_lock == VAR_FIXED) + { + PyErr_SetString(PyExc_TypeError, _("cannot modify fixed list")); + return -1; +*************** +*** 1250,1258 **** + if (istrue == -1) + return -1; + else if (istrue) +! this->list->lv_lock = VAR_LOCKED; + else +! this->list->lv_lock = 0; + } + return 0; + } +--- 1234,1242 ---- + if (istrue == -1) + return -1; + else if (istrue) +! self->list->lv_lock = VAR_LOCKED; + else +! self->list->lv_lock = 0; + } + return 0; + } +*************** +*** 1264,1271 **** + } + + static struct PyMethodDef ListMethods[] = { +! {"extend", (PyCFunction)ListConcatInPlace, METH_O, ""}, +! { NULL, NULL, 0, NULL } + }; + + typedef struct +--- 1248,1255 ---- + } + + static struct PyMethodDef ListMethods[] = { +! {"extend", (PyCFunction)ListConcatInPlace, METH_O, ""}, +! { NULL, NULL, 0, NULL } + }; + + typedef struct +*************** +*** 1296,1316 **** + } + + static void +! FunctionDestructor(PyObject *self) + { +! FunctionObject *this = (FunctionObject *) (self); +! +! func_unref(this->name); +! PyMem_Free(this->name); + + DESTRUCTOR_FINISH(self); + } + + static PyObject * +! FunctionCall(PyObject *self, PyObject *argsObject, PyObject *kwargs) + { +! FunctionObject *this = (FunctionObject *)(self); +! char_u *name = this->name; + typval_T args; + typval_T selfdicttv; + typval_T rettv; +--- 1280,1297 ---- + } + + static void +! FunctionDestructor(FunctionObject *self) + { +! func_unref(self->name); +! PyMem_Free(self->name); + + DESTRUCTOR_FINISH(self); + } + + static PyObject * +! FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs) + { +! char_u *name = self->name; + typval_T args; + typval_T selfdicttv; + typval_T rettv; +*************** +*** 1368,1375 **** + } + + static struct PyMethodDef FunctionMethods[] = { +! {"__call__", (PyCFunction)FunctionCall, METH_VARARGS|METH_KEYWORDS, ""}, +! { NULL, NULL, 0, NULL } + }; + + /* +--- 1349,1356 ---- + } + + static struct PyMethodDef FunctionMethods[] = { +! {"__call__", (PyCFunction)FunctionCall, METH_VARARGS|METH_KEYWORDS, ""}, +! { NULL, NULL, 0, NULL} + }; + + /* +*************** +*** 1415,1443 **** + } + + static void +! OptionsDestructor(PyObject *self) + { +! if (((OptionsObject *)(self))->fromObj) +! Py_DECREF(((OptionsObject *)(self))->fromObj); + DESTRUCTOR_FINISH(self); + } + + static int +! OptionsTraverse(PyObject *self, visitproc visit, void *arg) + { +! Py_VISIT(((OptionsObject *)(self))->fromObj); + return 0; + } + + static int +! OptionsClear(PyObject *self) + { +! Py_CLEAR(((OptionsObject *)(self))->fromObj); + return 0; + } + + static PyObject * +! OptionsItem(OptionsObject *this, PyObject *keyObject) + { + char_u *key; + int flags; +--- 1396,1424 ---- + } + + static void +! OptionsDestructor(OptionsObject *self) + { +! if (self->fromObj) +! Py_DECREF(self->fromObj); + DESTRUCTOR_FINISH(self); + } + + static int +! OptionsTraverse(OptionsObject *self, visitproc visit, void *arg) + { +! Py_VISIT(self->fromObj); + return 0; + } + + static int +! OptionsClear(OptionsObject *self) + { +! Py_CLEAR(self->fromObj); + return 0; + } + + static PyObject * +! OptionsItem(OptionsObject *self, PyObject *keyObject) + { + char_u *key; + int flags; +*************** +*** 1445,1457 **** + char_u *stringval; + DICTKEY_DECL + +! if (this->Check(this->from)) + return NULL; + + DICTKEY_GET_NOTEMPTY(NULL) + + flags = get_option_value_strict(key, &numval, &stringval, +! this->opt_type, this->from); + + DICTKEY_UNREF + +--- 1426,1438 ---- + char_u *stringval; + DICTKEY_DECL + +! if (self->Check(self->from)) + return NULL; + + DICTKEY_GET_NOTEMPTY(NULL) + + flags = get_option_value_strict(key, &numval, &stringval, +! self->opt_type, self->from); + + DICTKEY_UNREF + +*************** +*** 1532,1538 **** + } + + static int +! OptionsAssItem(OptionsObject *this, PyObject *keyObject, PyObject *valObject) + { + char_u *key; + int flags; +--- 1513,1519 ---- + } + + static int +! OptionsAssItem(OptionsObject *self, PyObject *keyObject, PyObject *valObject) + { + char_u *key; + int flags; +*************** +*** 1540,1552 **** + int r = 0; + DICTKEY_DECL + +! if (this->Check(this->from)) + return -1; + + DICTKEY_GET_NOTEMPTY(-1) + + flags = get_option_value_strict(key, NULL, NULL, +! this->opt_type, this->from); + + DICTKEY_UNREF + +--- 1521,1533 ---- + int r = 0; + DICTKEY_DECL + +! if (self->Check(self->from)) + return -1; + + DICTKEY_GET_NOTEMPTY(-1) + + flags = get_option_value_strict(key, NULL, NULL, +! self->opt_type, self->from); + + DICTKEY_UNREF + +*************** +*** 1558,1564 **** + + if (valObject == NULL) + { +! if (this->opt_type == SREQ_GLOBAL) + { + PyErr_SetString(PyExc_ValueError, + _("unable to unset global option")); +--- 1539,1545 ---- + + if (valObject == NULL) + { +! if (self->opt_type == SREQ_GLOBAL) + { + PyErr_SetString(PyExc_ValueError, + _("unable to unset global option")); +*************** +*** 1572,1583 **** + } + else + { +! unset_global_local_option(key, this->from); + return 0; + } + } + +! opt_flags = (this->opt_type ? OPT_LOCAL : OPT_GLOBAL); + + if (flags & SOPT_BOOL) + { +--- 1553,1564 ---- + } + else + { +! unset_global_local_option(key, self->from); + return 0; + } + } + +! opt_flags = (self->opt_type ? OPT_LOCAL : OPT_GLOBAL); + + if (flags & SOPT_BOOL) + { +*************** +*** 1585,1591 **** + if (istrue == -1) + return -1; + r = set_option_value_for(key, istrue, NULL, +! opt_flags, this->opt_type, this->from); + } + else if (flags & SOPT_NUM) + { +--- 1566,1572 ---- + if (istrue == -1) + return -1; + r = set_option_value_for(key, istrue, NULL, +! opt_flags, self->opt_type, self->from); + } + else if (flags & SOPT_NUM) + { +*************** +*** 1605,1611 **** + } + + r = set_option_value_for(key, val, NULL, opt_flags, +! this->opt_type, this->from); + } + else + { +--- 1586,1592 ---- + } + + r = set_option_value_for(key, val, NULL, opt_flags, +! self->opt_type, self->from); + } + else + { +*************** +*** 1643,1649 **** + } + + r = set_option_value_for(key, 0, val, opt_flags, +! this->opt_type, this->from); + vim_free(val); + } + +--- 1624,1630 ---- + } + + r = set_option_value_for(key, 0, val, opt_flags, +! self->opt_type, self->from); + vim_free(val); + } + +*************** +*** 1670,1678 **** + static PyTypeObject TabPageType; + + static int +! CheckTabPage(TabPageObject *this) + { +! if (this->tab == INVALID_TABPAGE_VALUE) + { + PyErr_SetVim(_("attempt to refer to deleted tab page")); + return -1; +--- 1651,1659 ---- + static PyTypeObject TabPageType; + + static int +! CheckTabPage(TabPageObject *self) + { +! if (self->tab == INVALID_TABPAGE_VALUE) + { + PyErr_SetVim(_("attempt to refer to deleted tab page")); + return -1; +*************** +*** 1704,1754 **** + } + + static void +! TabPageDestructor(PyObject *self) + { +! TabPageObject *this = (TabPageObject *)(self); +! +! if (this->tab && this->tab != INVALID_TABPAGE_VALUE) +! TAB_PYTHON_REF(this->tab) = NULL; + + DESTRUCTOR_FINISH(self); + } + + static PyObject * +! TabPageAttr(TabPageObject *this, char *name) + { + if (strcmp(name, "windows") == 0) +! return WinListNew(this); + else if (strcmp(name, "number") == 0) +! return PyLong_FromLong((long) get_tab_number(this->tab)); + else if (strcmp(name, "vars") == 0) +! return DictionaryNew(this->tab->tp_vars); + else if (strcmp(name, "window") == 0) + { + /* For current tab window.c does not bother to set or update tp_curwin + */ +! if (this->tab == curtab) + return WindowNew(curwin, curtab); + else +! return WindowNew(this->tab->tp_curwin, this->tab); + } + return NULL; + } + + static PyObject * +! TabPageRepr(PyObject *self) + { + static char repr[100]; +- TabPageObject *this = (TabPageObject *)(self); + +! if (this->tab == INVALID_TABPAGE_VALUE) + { + vim_snprintf(repr, 100, _(""), (self)); + return PyString_FromString(repr); + } + else + { +! int t = get_tab_number(this->tab); + + if (t == 0) + vim_snprintf(repr, 100, _(""), +--- 1685,1732 ---- + } + + static void +! TabPageDestructor(TabPageObject *self) + { +! if (self->tab && self->tab != INVALID_TABPAGE_VALUE) +! TAB_PYTHON_REF(self->tab) = NULL; + + DESTRUCTOR_FINISH(self); + } + + static PyObject * +! TabPageAttr(TabPageObject *self, char *name) + { + if (strcmp(name, "windows") == 0) +! return WinListNew(self); + else if (strcmp(name, "number") == 0) +! return PyLong_FromLong((long) get_tab_number(self->tab)); + else if (strcmp(name, "vars") == 0) +! return DictionaryNew(self->tab->tp_vars); + else if (strcmp(name, "window") == 0) + { + /* For current tab window.c does not bother to set or update tp_curwin + */ +! if (self->tab == curtab) + return WindowNew(curwin, curtab); + else +! return WindowNew(self->tab->tp_curwin, self->tab); + } + return NULL; + } + + static PyObject * +! TabPageRepr(TabPageObject *self) + { + static char repr[100]; + +! if (self->tab == INVALID_TABPAGE_VALUE) + { + vim_snprintf(repr, 100, _(""), (self)); + return PyString_FromString(repr); + } + else + { +! int t = get_tab_number(self->tab); + + if (t == 0) + vim_snprintf(repr, 100, _(""), +*************** +*** 1818,1826 **** + static PyTypeObject WindowType; + + static int +! CheckWindow(WindowObject *this) + { +! if (this->win == INVALID_WINDOW_VALUE) + { + PyErr_SetVim(_("attempt to refer to deleted window")); + return -1; +--- 1796,1804 ---- + static PyTypeObject WindowType; + + static int +! CheckWindow(WindowObject *self) + { +! if (self->win == INVALID_WINDOW_VALUE) + { + PyErr_SetVim(_("attempt to refer to deleted window")); + return -1; +*************** +*** 1869,1882 **** + } + + static void +! WindowDestructor(PyObject *self) + { +! WindowObject *this = (WindowObject *)(self); +! +! if (this->win && this->win != INVALID_WINDOW_VALUE) +! WIN_PYTHON_REF(this->win) = NULL; + +! Py_DECREF(((PyObject *)(this->tabObject))); + + DESTRUCTOR_FINISH(self); + } +--- 1847,1858 ---- + } + + static void +! WindowDestructor(WindowObject *self) + { +! if (self->win && self->win != INVALID_WINDOW_VALUE) +! WIN_PYTHON_REF(self->win) = NULL; + +! Py_DECREF(((PyObject *)(self->tabObject))); + + DESTRUCTOR_FINISH(self); + } +*************** +*** 1899,1956 **** + return firstwin; + } + static int +! WindowTraverse(PyObject *self, visitproc visit, void *arg) + { +! Py_VISIT(((PyObject *)(((WindowObject *)(self))->tabObject))); + return 0; + } + + static int +! WindowClear(PyObject *self) + { +! Py_CLEAR((((WindowObject *)(self))->tabObject)); + return 0; + } + + static PyObject * +! WindowAttr(WindowObject *this, char *name) + { + if (strcmp(name, "buffer") == 0) +! return (PyObject *)BufferNew(this->win->w_buffer); + else if (strcmp(name, "cursor") == 0) + { +! pos_T *pos = &this->win->w_cursor; + + return Py_BuildValue("(ll)", (long)(pos->lnum), (long)(pos->col)); + } + else if (strcmp(name, "height") == 0) +! return PyLong_FromLong((long)(this->win->w_height)); + #ifdef FEAT_WINDOWS + else if (strcmp(name, "row") == 0) +! return PyLong_FromLong((long)(this->win->w_winrow)); + #endif + #ifdef FEAT_VERTSPLIT + else if (strcmp(name, "width") == 0) +! return PyLong_FromLong((long)(W_WIDTH(this->win))); + else if (strcmp(name, "col") == 0) +! return PyLong_FromLong((long)(W_WINCOL(this->win))); + #endif + else if (strcmp(name, "vars") == 0) +! return DictionaryNew(this->win->w_vars); + else if (strcmp(name, "options") == 0) +! return OptionsNew(SREQ_WIN, this->win, (checkfun) CheckWindow, +! (PyObject *) this); + else if (strcmp(name, "number") == 0) + { +! if (CheckTabPage(this->tabObject)) + return NULL; + return PyLong_FromLong((long) +! get_win_number(this->win, get_firstwin(this->tabObject))); + } + else if (strcmp(name, "tabpage") == 0) + { +! Py_INCREF(this->tabObject); +! return (PyObject *)(this->tabObject); + } + else if (strcmp(name,"__members__") == 0) + return Py_BuildValue("[sssssssss]", "buffer", "cursor", "height", +--- 1875,1932 ---- + return firstwin; + } + static int +! WindowTraverse(WindowObject *self, visitproc visit, void *arg) + { +! Py_VISIT(((PyObject *)(self->tabObject))); + return 0; + } + + static int +! WindowClear(WindowObject *self) + { +! Py_CLEAR(self->tabObject); + return 0; + } + + static PyObject * +! WindowAttr(WindowObject *self, char *name) + { + if (strcmp(name, "buffer") == 0) +! return (PyObject *)BufferNew(self->win->w_buffer); + else if (strcmp(name, "cursor") == 0) + { +! pos_T *pos = &self->win->w_cursor; + + return Py_BuildValue("(ll)", (long)(pos->lnum), (long)(pos->col)); + } + else if (strcmp(name, "height") == 0) +! return PyLong_FromLong((long)(self->win->w_height)); + #ifdef FEAT_WINDOWS + else if (strcmp(name, "row") == 0) +! return PyLong_FromLong((long)(self->win->w_winrow)); + #endif + #ifdef FEAT_VERTSPLIT + else if (strcmp(name, "width") == 0) +! return PyLong_FromLong((long)(W_WIDTH(self->win))); + else if (strcmp(name, "col") == 0) +! return PyLong_FromLong((long)(W_WINCOL(self->win))); + #endif + else if (strcmp(name, "vars") == 0) +! return DictionaryNew(self->win->w_vars); + else if (strcmp(name, "options") == 0) +! return OptionsNew(SREQ_WIN, self->win, (checkfun) CheckWindow, +! (PyObject *) self); + else if (strcmp(name, "number") == 0) + { +! if (CheckTabPage(self->tabObject)) + return NULL; + return PyLong_FromLong((long) +! get_win_number(self->win, get_firstwin(self->tabObject))); + } + else if (strcmp(name, "tabpage") == 0) + { +! Py_INCREF(self->tabObject); +! return (PyObject *)(self->tabObject); + } + else if (strcmp(name,"__members__") == 0) + return Py_BuildValue("[sssssssss]", "buffer", "cursor", "height", +*************** +*** 1960,1970 **** + } + + static int +! WindowSetattr(PyObject *self, char *name, PyObject *val) + { +! WindowObject *this = (WindowObject *)(self); +! +! if (CheckWindow(this)) + return -1; + + if (strcmp(name, "buffer") == 0) +--- 1936,1944 ---- + } + + static int +! WindowSetattr(WindowObject *self, char *name, PyObject *val) + { +! if (CheckWindow(self)) + return -1; + + if (strcmp(name, "buffer") == 0) +*************** +*** 1980,1986 **** + if (!PyArg_Parse(val, "(ll)", &lnum, &col)) + return -1; + +! if (lnum <= 0 || lnum > this->win->w_buffer->b_ml.ml_line_count) + { + PyErr_SetVim(_("cursor position outside buffer")); + return -1; +--- 1954,1960 ---- + if (!PyArg_Parse(val, "(ll)", &lnum, &col)) + return -1; + +! if (lnum <= 0 || lnum > self->win->w_buffer->b_ml.ml_line_count) + { + PyErr_SetVim(_("cursor position outside buffer")); + return -1; +*************** +*** 1990,2002 **** + if (VimErrorCheck()) + return -1; + +! this->win->w_cursor.lnum = lnum; +! this->win->w_cursor.col = col; + #ifdef FEAT_VIRTUALEDIT +! this->win->w_cursor.coladd = 0; + #endif + /* When column is out of range silently correct it. */ +! check_cursor_col_win(this->win); + + update_screen(VALID); + return 0; +--- 1964,1976 ---- + if (VimErrorCheck()) + return -1; + +! self->win->w_cursor.lnum = lnum; +! self->win->w_cursor.col = col; + #ifdef FEAT_VIRTUALEDIT +! self->win->w_cursor.coladd = 0; + #endif + /* When column is out of range silently correct it. */ +! check_cursor_col_win(self->win); + + update_screen(VALID); + return 0; +*************** +*** 2013,2019 **** + need_mouse_correct = TRUE; + #endif + savewin = curwin; +! curwin = this->win; + win_setheight(height); + curwin = savewin; + +--- 1987,1993 ---- + need_mouse_correct = TRUE; + #endif + savewin = curwin; +! curwin = self->win; + win_setheight(height); + curwin = savewin; + +*************** +*** 2036,2042 **** + need_mouse_correct = TRUE; + #endif + savewin = curwin; +! curwin = this->win; + win_setwidth(width); + curwin = savewin; + +--- 2010,2016 ---- + need_mouse_correct = TRUE; + #endif + savewin = curwin; +! curwin = self->win; + win_setwidth(width); + curwin = savewin; + +*************** +*** 2055,2073 **** + } + + static PyObject * +! WindowRepr(PyObject *self) + { + static char repr[100]; +- WindowObject *this = (WindowObject *)(self); + +! if (this->win == INVALID_WINDOW_VALUE) + { + vim_snprintf(repr, 100, _(""), (self)); + return PyString_FromString(repr); + } + else + { +! int w = get_win_number(this->win, firstwin); + + if (w == 0) + vim_snprintf(repr, 100, _(""), +--- 2029,2046 ---- + } + + static PyObject * +! WindowRepr(WindowObject *self) + { + static char repr[100]; + +! if (self->win == INVALID_WINDOW_VALUE) + { + vim_snprintf(repr, 100, _(""), (self)); + return PyString_FromString(repr); + } + else + { +! int w = get_win_number(self->win, firstwin); + + if (w == 0) + vim_snprintf(repr, 100, _(""), +*************** +*** 2110,2118 **** + } + + static void +! WinListDestructor(PyObject *self) + { +! TabPageObject *tabObject = ((WinListObject *)(self))->tabObject; + + if (tabObject) + Py_DECREF((PyObject *)(tabObject)); +--- 2083,2091 ---- + } + + static void +! WinListDestructor(WinListObject *self) + { +! TabPageObject *tabObject = self->tabObject; + + if (tabObject) + Py_DECREF((PyObject *)(tabObject)); +*************** +*** 2121,2132 **** + } + + static PyInt +! WinListLength(PyObject *self) + { + win_T *w; + PyInt n = 0; + +! if (!(w = get_firstwin(((WinListObject *)(self))->tabObject))) + return -1; + + while (w != NULL) +--- 2094,2105 ---- + } + + static PyInt +! WinListLength(WinListObject *self) + { + win_T *w; + PyInt n = 0; + +! if (!(w = get_firstwin(self->tabObject))) + return -1; + + while (w != NULL) +*************** +*** 2139,2155 **** + } + + static PyObject * +! WinListItem(PyObject *self, PyInt n) + { +- WinListObject *this = ((WinListObject *)(self)); + win_T *w; + +! if (!(w = get_firstwin(this->tabObject))) + return NULL; + + for (; w != NULL; w = W_NEXT(w), --n) + if (n == 0) +! return WindowNew(w, this->tabObject? this->tabObject->tab: curtab); + + PyErr_SetString(PyExc_IndexError, _("no such window")); + return NULL; +--- 2112,2127 ---- + } + + static PyObject * +! WinListItem(WinListObject *self, PyInt n) + { + win_T *w; + +! if (!(w = get_firstwin(self->tabObject))) + return NULL; + + for (; w != NULL; w = W_NEXT(w), --n) + if (n == 0) +! return WindowNew(w, self->tabObject? self->tabObject->tab: curtab); + + PyErr_SetString(PyExc_IndexError, _("no such window")); + return NULL; +*************** +*** 2721,2729 **** + } BufferObject; + + static int +! CheckBuffer(BufferObject *this) + { +! if (this->buf == INVALID_BUFFER_VALUE) + { + PyErr_SetVim(_("attempt to refer to deleted buffer")); + return -1; +--- 2693,2701 ---- + } BufferObject; + + static int +! CheckBuffer(BufferObject *self) + { +! if (self->buf == INVALID_BUFFER_VALUE) + { + PyErr_SetVim(_("attempt to refer to deleted buffer")); + return -1; +*************** +*** 2922,2975 **** + } + + static void +! RangeDestructor(PyObject *self) + { +! Py_DECREF(((RangeObject *)(self))->buf); + DESTRUCTOR_FINISH(self); + } + + static PyInt +! RangeLength(PyObject *self) + { + /* HOW DO WE SIGNAL AN ERROR FROM THIS FUNCTION? */ +! if (CheckBuffer(((RangeObject *)(self))->buf)) + return -1; /* ??? */ + +! return (((RangeObject *)(self))->end - ((RangeObject *)(self))->start + 1); + } + + static PyObject * +! RangeItem(PyObject *self, PyInt n) + { +! return RBItem(((RangeObject *)(self))->buf, n, +! ((RangeObject *)(self))->start, +! ((RangeObject *)(self))->end); + } + + static PyObject * +! RangeSlice(PyObject *self, PyInt lo, PyInt hi) + { +! return RBSlice(((RangeObject *)(self))->buf, lo, hi, +! ((RangeObject *)(self))->start, +! ((RangeObject *)(self))->end); + } + + static PyObject * +! RangeAppend(PyObject *self, PyObject *args) + { +! return RBAppend(((RangeObject *)(self))->buf, args, +! ((RangeObject *)(self))->start, +! ((RangeObject *)(self))->end, +! &((RangeObject *)(self))->end); + } + + static PyObject * +! RangeRepr(PyObject *self) + { + static char repr[100]; +- RangeObject *this = (RangeObject *)(self); + +! if (this->buf->buf == INVALID_BUFFER_VALUE) + { + vim_snprintf(repr, 100, "", + (self)); +--- 2894,2939 ---- + } + + static void +! RangeDestructor(RangeObject *self) + { +! Py_DECREF(self->buf); + DESTRUCTOR_FINISH(self); + } + + static PyInt +! RangeLength(RangeObject *self) + { + /* HOW DO WE SIGNAL AN ERROR FROM THIS FUNCTION? */ +! if (CheckBuffer(self->buf)) + return -1; /* ??? */ + +! return (self->end - self->start + 1); + } + + static PyObject * +! RangeItem(RangeObject *self, PyInt n) + { +! return RBItem(self->buf, n, self->start, self->end); + } + + static PyObject * +! RangeSlice(RangeObject *self, PyInt lo, PyInt hi) + { +! return RBSlice(self->buf, lo, hi, self->start, self->end); + } + + static PyObject * +! RangeAppend(RangeObject *self, PyObject *args) + { +! return RBAppend(self->buf, args, self->start, self->end, &self->end); + } + + static PyObject * +! RangeRepr(RangeObject *self) + { + static char repr[100]; + +! if (self->buf->buf == INVALID_BUFFER_VALUE) + { + vim_snprintf(repr, 100, "", + (self)); +*************** +*** 2977,2983 **** + } + else + { +! char *name = (char *)this->buf->buf->b_fname; + int len; + + if (name == NULL) +--- 2941,2947 ---- + } + else + { +! char *name = (char *)self->buf->buf->b_fname; + int len; + + if (name == NULL) +*************** +*** 2989,3004 **** + + vim_snprintf(repr, 100, "", + len > 45 ? "..." : "", name, +! this->start, this->end); + + return PyString_FromString(repr); + } + } + + static struct PyMethodDef RangeMethods[] = { +! /* name, function, calling, documentation */ +! {"append", RangeAppend, 1, "Append data to the Vim range" }, +! { NULL, NULL, 0, NULL } + }; + + static PyTypeObject BufferType; +--- 2953,2968 ---- + + vim_snprintf(repr, 100, "", + len > 45 ? "..." : "", name, +! self->start, self->end); + + return PyString_FromString(repr); + } + } + + static struct PyMethodDef RangeMethods[] = { +! /* name, function, calling, documentation */ +! {"append", (PyCFunction)RangeAppend, METH_VARARGS, "Append data to the Vim range" }, +! { NULL, NULL, 0, NULL } + }; + + static PyTypeObject BufferType; +*************** +*** 3045,3094 **** + } + + static void +! BufferDestructor(PyObject *self) + { +! BufferObject *this = (BufferObject *)(self); +! +! if (this->buf && this->buf != INVALID_BUFFER_VALUE) +! BUF_PYTHON_REF(this->buf) = NULL; + + DESTRUCTOR_FINISH(self); + } + + static PyInt +! BufferLength(PyObject *self) + { + /* HOW DO WE SIGNAL AN ERROR FROM THIS FUNCTION? */ +! if (CheckBuffer((BufferObject *)(self))) + return -1; /* ??? */ + +! return (PyInt)(((BufferObject *)(self))->buf->b_ml.ml_line_count); + } + + static PyObject * +! BufferItem(PyObject *self, PyInt n) + { +! return RBItem((BufferObject *)(self), n, 1, -1); + } + + static PyObject * +! BufferSlice(PyObject *self, PyInt lo, PyInt hi) + { +! return RBSlice((BufferObject *)(self), lo, hi, 1, -1); + } + + static PyObject * +! BufferAttr(BufferObject *this, char *name) + { + if (strcmp(name, "name") == 0) +! return Py_BuildValue("s", this->buf->b_ffname); + else if (strcmp(name, "number") == 0) +! return Py_BuildValue(Py_ssize_t_fmt, this->buf->b_fnum); + else if (strcmp(name, "vars") == 0) +! return DictionaryNew(this->buf->b_vars); + else if (strcmp(name, "options") == 0) +! return OptionsNew(SREQ_BUF, this->buf, (checkfun) CheckBuffer, +! (PyObject *) this); + else if (strcmp(name,"__members__") == 0) + return Py_BuildValue("[ssss]", "name", "number", "vars", "options"); + else +--- 3009,3056 ---- + } + + static void +! BufferDestructor(BufferObject *self) + { +! if (self->buf && self->buf != INVALID_BUFFER_VALUE) +! BUF_PYTHON_REF(self->buf) = NULL; + + DESTRUCTOR_FINISH(self); + } + + static PyInt +! BufferLength(BufferObject *self) + { + /* HOW DO WE SIGNAL AN ERROR FROM THIS FUNCTION? */ +! if (CheckBuffer(self)) + return -1; /* ??? */ + +! return (PyInt)(self->buf->b_ml.ml_line_count); + } + + static PyObject * +! BufferItem(BufferObject *self, PyInt n) + { +! return RBItem(self, n, 1, -1); + } + + static PyObject * +! BufferSlice(BufferObject *self, PyInt lo, PyInt hi) + { +! return RBSlice(self, lo, hi, 1, -1); + } + + static PyObject * +! BufferAttr(BufferObject *self, char *name) + { + if (strcmp(name, "name") == 0) +! return Py_BuildValue("s", self->buf->b_ffname); + else if (strcmp(name, "number") == 0) +! return Py_BuildValue(Py_ssize_t_fmt, self->buf->b_fnum); + else if (strcmp(name, "vars") == 0) +! return DictionaryNew(self->buf->b_vars); + else if (strcmp(name, "options") == 0) +! return OptionsNew(SREQ_BUF, self->buf, (checkfun) CheckBuffer, +! (PyObject *) self); + else if (strcmp(name,"__members__") == 0) + return Py_BuildValue("[ssss]", "name", "number", "vars", "options"); + else +*************** +*** 3096,3122 **** + } + + static PyObject * +! BufferAppend(PyObject *self, PyObject *args) + { +! return RBAppend((BufferObject *)(self), args, 1, -1, NULL); + } + + static PyObject * +! BufferMark(PyObject *self, PyObject *args) + { + pos_T *posp; + char *pmark; + char mark; + buf_T *savebuf; + +! if (CheckBuffer((BufferObject *)(self))) + return NULL; + + if (!PyArg_ParseTuple(args, "s", &pmark)) + return NULL; + mark = *pmark; + +! switch_buffer(&savebuf, ((BufferObject *)(self))->buf); + posp = getmark(mark, FALSE); + restore_buffer(savebuf); + +--- 3058,3084 ---- + } + + static PyObject * +! BufferAppend(BufferObject *self, PyObject *args) + { +! return RBAppend(self, args, 1, -1, NULL); + } + + static PyObject * +! BufferMark(BufferObject *self, PyObject *args) + { + pos_T *posp; + char *pmark; + char mark; + buf_T *savebuf; + +! if (CheckBuffer(self)) + return NULL; + + if (!PyArg_ParseTuple(args, "s", &pmark)) + return NULL; + mark = *pmark; + +! switch_buffer(&savebuf, self->buf); + posp = getmark(mark, FALSE); + restore_buffer(savebuf); + +*************** +*** 3141,3174 **** + } + + static PyObject * +! BufferRange(PyObject *self, PyObject *args) + { + PyInt start; + PyInt end; + +! if (CheckBuffer((BufferObject *)(self))) + return NULL; + + if (!PyArg_ParseTuple(args, "nn", &start, &end)) + return NULL; + +! return RangeNew(((BufferObject *)(self))->buf, start, end); + } + + static PyObject * +! BufferRepr(PyObject *self) + { + static char repr[100]; +- BufferObject *this = (BufferObject *)(self); + +! if (this->buf == INVALID_BUFFER_VALUE) + { + vim_snprintf(repr, 100, _(""), (self)); + return PyString_FromString(repr); + } + else + { +! char *name = (char *)this->buf->b_fname; + PyInt len; + + if (name == NULL) +--- 3103,3135 ---- + } + + static PyObject * +! BufferRange(BufferObject *self, PyObject *args) + { + PyInt start; + PyInt end; + +! if (CheckBuffer(self)) + return NULL; + + if (!PyArg_ParseTuple(args, "nn", &start, &end)) + return NULL; + +! return RangeNew(self->buf, start, end); + } + + static PyObject * +! BufferRepr(BufferObject *self) + { + static char repr[100]; + +! if (self->buf == INVALID_BUFFER_VALUE) + { + vim_snprintf(repr, 100, _(""), (self)); + return PyString_FromString(repr); + } + else + { +! char *name = (char *)self->buf->b_fname; + PyInt len; + + if (name == NULL) +*************** +*** 3185,3198 **** + } + + static struct PyMethodDef BufferMethods[] = { +! /* name, function, calling, documentation */ +! {"append", BufferAppend, 1, "Append data to Vim buffer" }, +! {"mark", BufferMark, 1, "Return (row,col) representing position of named mark" }, +! {"range", BufferRange, 1, "Return a range object which represents the part of the given buffer between line numbers s and e" }, + #if PY_VERSION_HEX >= 0x03000000 +! {"__dir__", BufferDir, 4, "List its attributes" }, + #endif +! { NULL, NULL, 0, NULL } + }; + + /* +--- 3146,3159 ---- + } + + static struct PyMethodDef BufferMethods[] = { +! /* name, function, calling, documentation */ +! {"append", (PyCFunction)BufferAppend, METH_VARARGS, "Append data to Vim buffer" }, +! {"mark", (PyCFunction)BufferMark, METH_VARARGS, "Return (row,col) representing position of named mark" }, +! {"range", (PyCFunction)BufferRange, METH_VARARGS, "Return a range object which represents the part of the given buffer between line numbers s and e" }, + #if PY_VERSION_HEX >= 0x03000000 +! {"__dir__", (PyCFunction)BufferDir, METH_NOARGS, "List buffer attributes" }, + #endif +! { NULL, NULL, 0, NULL } + }; + + /* +*************** +*** 4021,4034 **** + OutputType.tp_doc = "vim message object"; + OutputType.tp_methods = OutputMethods; + #if PY_MAJOR_VERSION >= 3 +! OutputType.tp_getattro = OutputGetattro; +! OutputType.tp_setattro = OutputSetattro; + OutputType.tp_alloc = call_PyType_GenericAlloc; + OutputType.tp_new = call_PyType_GenericNew; + OutputType.tp_free = call_PyObject_Free; + #else +! OutputType.tp_getattr = OutputGetattr; +! OutputType.tp_setattr = OutputSetattr; + #endif + + vim_memset(&IterType, 0, sizeof(IterType)); +--- 3982,3995 ---- + OutputType.tp_doc = "vim message object"; + OutputType.tp_methods = OutputMethods; + #if PY_MAJOR_VERSION >= 3 +! OutputType.tp_getattro = (getattrofunc)OutputGetattro; +! OutputType.tp_setattro = (setattrofunc)OutputSetattro; + OutputType.tp_alloc = call_PyType_GenericAlloc; + OutputType.tp_new = call_PyType_GenericNew; + OutputType.tp_free = call_PyObject_Free; + #else +! OutputType.tp_getattr = (getattrfunc)OutputGetattr; +! OutputType.tp_setattr = (setattrfunc)OutputSetattr; + #endif + + vim_memset(&IterType, 0, sizeof(IterType)); +*************** +*** 4036,4102 **** + IterType.tp_basicsize = sizeof(IterObject); + IterType.tp_flags = Py_TPFLAGS_DEFAULT; + IterType.tp_doc = "generic iterator object"; +! IterType.tp_iter = IterIter; +! IterType.tp_iternext = IterNext; +! IterType.tp_dealloc = IterDestructor; +! IterType.tp_traverse = IterTraverse; +! IterType.tp_clear = IterClear; + + vim_memset(&BufferType, 0, sizeof(BufferType)); + BufferType.tp_name = "vim.buffer"; + BufferType.tp_basicsize = sizeof(BufferType); +! BufferType.tp_dealloc = BufferDestructor; +! BufferType.tp_repr = BufferRepr; + BufferType.tp_as_sequence = &BufferAsSeq; + BufferType.tp_as_mapping = &BufferAsMapping; + BufferType.tp_flags = Py_TPFLAGS_DEFAULT; + BufferType.tp_doc = "vim buffer object"; + BufferType.tp_methods = BufferMethods; + #if PY_MAJOR_VERSION >= 3 +! BufferType.tp_getattro = BufferGetattro; + BufferType.tp_alloc = call_PyType_GenericAlloc; + BufferType.tp_new = call_PyType_GenericNew; + BufferType.tp_free = call_PyObject_Free; + #else +! BufferType.tp_getattr = BufferGetattr; + #endif + + vim_memset(&WindowType, 0, sizeof(WindowType)); + WindowType.tp_name = "vim.window"; + WindowType.tp_basicsize = sizeof(WindowObject); +! WindowType.tp_dealloc = WindowDestructor; +! WindowType.tp_repr = WindowRepr; + WindowType.tp_flags = Py_TPFLAGS_DEFAULT; + WindowType.tp_doc = "vim Window object"; + WindowType.tp_methods = WindowMethods; +! WindowType.tp_traverse = WindowTraverse; +! WindowType.tp_clear = WindowClear; + #if PY_MAJOR_VERSION >= 3 +! WindowType.tp_getattro = WindowGetattro; +! WindowType.tp_setattro = WindowSetattro; + WindowType.tp_alloc = call_PyType_GenericAlloc; + WindowType.tp_new = call_PyType_GenericNew; + WindowType.tp_free = call_PyObject_Free; + #else +! WindowType.tp_getattr = WindowGetattr; +! WindowType.tp_setattr = WindowSetattr; + #endif + + vim_memset(&TabPageType, 0, sizeof(TabPageType)); + TabPageType.tp_name = "vim.tabpage"; + TabPageType.tp_basicsize = sizeof(TabPageObject); +! TabPageType.tp_dealloc = TabPageDestructor; +! TabPageType.tp_repr = TabPageRepr; + TabPageType.tp_flags = Py_TPFLAGS_DEFAULT; + TabPageType.tp_doc = "vim tab page object"; + TabPageType.tp_methods = TabPageMethods; + #if PY_MAJOR_VERSION >= 3 +! TabPageType.tp_getattro = TabPageGetattro; + TabPageType.tp_alloc = call_PyType_GenericAlloc; + TabPageType.tp_new = call_PyType_GenericNew; + TabPageType.tp_free = call_PyObject_Free; + #else +! TabPageType.tp_getattr = TabPageGetattr; + #endif + + vim_memset(&BufMapType, 0, sizeof(BufMapType)); +--- 3997,4063 ---- + IterType.tp_basicsize = sizeof(IterObject); + IterType.tp_flags = Py_TPFLAGS_DEFAULT; + IterType.tp_doc = "generic iterator object"; +! IterType.tp_iter = (getiterfunc)IterIter; +! IterType.tp_iternext = (iternextfunc)IterNext; +! IterType.tp_dealloc = (destructor)IterDestructor; +! IterType.tp_traverse = (traverseproc)IterTraverse; +! IterType.tp_clear = (inquiry)IterClear; + + vim_memset(&BufferType, 0, sizeof(BufferType)); + BufferType.tp_name = "vim.buffer"; + BufferType.tp_basicsize = sizeof(BufferType); +! BufferType.tp_dealloc = (destructor)BufferDestructor; +! BufferType.tp_repr = (reprfunc)BufferRepr; + BufferType.tp_as_sequence = &BufferAsSeq; + BufferType.tp_as_mapping = &BufferAsMapping; + BufferType.tp_flags = Py_TPFLAGS_DEFAULT; + BufferType.tp_doc = "vim buffer object"; + BufferType.tp_methods = BufferMethods; + #if PY_MAJOR_VERSION >= 3 +! BufferType.tp_getattro = (getattrofunc)BufferGetattro; + BufferType.tp_alloc = call_PyType_GenericAlloc; + BufferType.tp_new = call_PyType_GenericNew; + BufferType.tp_free = call_PyObject_Free; + #else +! BufferType.tp_getattr = (getattrfunc)BufferGetattr; + #endif + + vim_memset(&WindowType, 0, sizeof(WindowType)); + WindowType.tp_name = "vim.window"; + WindowType.tp_basicsize = sizeof(WindowObject); +! WindowType.tp_dealloc = (destructor)WindowDestructor; +! WindowType.tp_repr = (reprfunc)WindowRepr; + WindowType.tp_flags = Py_TPFLAGS_DEFAULT; + WindowType.tp_doc = "vim Window object"; + WindowType.tp_methods = WindowMethods; +! WindowType.tp_traverse = (traverseproc)WindowTraverse; +! WindowType.tp_clear = (inquiry)WindowClear; + #if PY_MAJOR_VERSION >= 3 +! WindowType.tp_getattro = (getattrofunc)WindowGetattro; +! WindowType.tp_setattro = (setattrofunc)WindowSetattro; + WindowType.tp_alloc = call_PyType_GenericAlloc; + WindowType.tp_new = call_PyType_GenericNew; + WindowType.tp_free = call_PyObject_Free; + #else +! WindowType.tp_getattr = (getattrfunc)WindowGetattr; +! WindowType.tp_setattr = (setattrfunc)WindowSetattr; + #endif + + vim_memset(&TabPageType, 0, sizeof(TabPageType)); + TabPageType.tp_name = "vim.tabpage"; + TabPageType.tp_basicsize = sizeof(TabPageObject); +! TabPageType.tp_dealloc = (destructor)TabPageDestructor; +! TabPageType.tp_repr = (reprfunc)TabPageRepr; + TabPageType.tp_flags = Py_TPFLAGS_DEFAULT; + TabPageType.tp_doc = "vim tab page object"; + TabPageType.tp_methods = TabPageMethods; + #if PY_MAJOR_VERSION >= 3 +! TabPageType.tp_getattro = (getattrofunc)TabPageGetattro; + TabPageType.tp_alloc = call_PyType_GenericAlloc; + TabPageType.tp_new = call_PyType_GenericNew; + TabPageType.tp_free = call_PyObject_Free; + #else +! TabPageType.tp_getattr = (getattrfunc)TabPageGetattr; + #endif + + vim_memset(&BufMapType, 0, sizeof(BufMapType)); +*************** +*** 4113,4119 **** + WinListType.tp_as_sequence = &WinListAsSeq; + WinListType.tp_flags = Py_TPFLAGS_DEFAULT; + WinListType.tp_doc = "vim window list"; +! WinListType.tp_dealloc = WinListDestructor; + + vim_memset(&TabListType, 0, sizeof(TabListType)); + TabListType.tp_name = "vim.tabpagelist"; +--- 4074,4080 ---- + WinListType.tp_as_sequence = &WinListAsSeq; + WinListType.tp_flags = Py_TPFLAGS_DEFAULT; + WinListType.tp_doc = "vim window list"; +! WinListType.tp_dealloc = (destructor)WinListDestructor; + + vim_memset(&TabListType, 0, sizeof(TabListType)); + TabListType.tp_name = "vim.tabpagelist"; +*************** +*** 4125,4144 **** + vim_memset(&RangeType, 0, sizeof(RangeType)); + RangeType.tp_name = "vim.range"; + RangeType.tp_basicsize = sizeof(RangeObject); +! RangeType.tp_dealloc = RangeDestructor; +! RangeType.tp_repr = RangeRepr; + RangeType.tp_as_sequence = &RangeAsSeq; + RangeType.tp_as_mapping = &RangeAsMapping; + RangeType.tp_flags = Py_TPFLAGS_DEFAULT; + RangeType.tp_doc = "vim Range object"; + RangeType.tp_methods = RangeMethods; + #if PY_MAJOR_VERSION >= 3 +! RangeType.tp_getattro = RangeGetattro; + RangeType.tp_alloc = call_PyType_GenericAlloc; + RangeType.tp_new = call_PyType_GenericNew; + RangeType.tp_free = call_PyObject_Free; + #else +! RangeType.tp_getattr = RangeGetattr; + #endif + + vim_memset(&CurrentType, 0, sizeof(CurrentType)); +--- 4086,4105 ---- + vim_memset(&RangeType, 0, sizeof(RangeType)); + RangeType.tp_name = "vim.range"; + RangeType.tp_basicsize = sizeof(RangeObject); +! RangeType.tp_dealloc = (destructor)RangeDestructor; +! RangeType.tp_repr = (reprfunc)RangeRepr; + RangeType.tp_as_sequence = &RangeAsSeq; + RangeType.tp_as_mapping = &RangeAsMapping; + RangeType.tp_flags = Py_TPFLAGS_DEFAULT; + RangeType.tp_doc = "vim Range object"; + RangeType.tp_methods = RangeMethods; + #if PY_MAJOR_VERSION >= 3 +! RangeType.tp_getattro = (getattrofunc)RangeGetattro; + RangeType.tp_alloc = call_PyType_GenericAlloc; + RangeType.tp_new = call_PyType_GenericNew; + RangeType.tp_free = call_PyObject_Free; + #else +! RangeType.tp_getattr = (getattrfunc)RangeGetattr; + #endif + + vim_memset(&CurrentType, 0, sizeof(CurrentType)); +*************** +*** 4147,4205 **** + CurrentType.tp_flags = Py_TPFLAGS_DEFAULT; + CurrentType.tp_doc = "vim current object"; + #if PY_MAJOR_VERSION >= 3 +! CurrentType.tp_getattro = CurrentGetattro; +! CurrentType.tp_setattro = CurrentSetattro; + #else +! CurrentType.tp_getattr = CurrentGetattr; +! CurrentType.tp_setattr = CurrentSetattr; + #endif + + vim_memset(&DictionaryType, 0, sizeof(DictionaryType)); + DictionaryType.tp_name = "vim.dictionary"; + DictionaryType.tp_basicsize = sizeof(DictionaryObject); +! DictionaryType.tp_dealloc = DictionaryDestructor; + DictionaryType.tp_as_mapping = &DictionaryAsMapping; + DictionaryType.tp_flags = Py_TPFLAGS_DEFAULT; + DictionaryType.tp_doc = "dictionary pushing modifications to vim structure"; + DictionaryType.tp_methods = DictionaryMethods; + #if PY_MAJOR_VERSION >= 3 +! DictionaryType.tp_getattro = DictionaryGetattro; +! DictionaryType.tp_setattro = DictionarySetattro; + #else +! DictionaryType.tp_getattr = DictionaryGetattr; +! DictionaryType.tp_setattr = DictionarySetattr; + #endif + + vim_memset(&ListType, 0, sizeof(ListType)); + ListType.tp_name = "vim.list"; +! ListType.tp_dealloc = ListDestructor; + ListType.tp_basicsize = sizeof(ListObject); + ListType.tp_as_sequence = &ListAsSeq; + ListType.tp_as_mapping = &ListAsMapping; + ListType.tp_flags = Py_TPFLAGS_DEFAULT; + ListType.tp_doc = "list pushing modifications to vim structure"; + ListType.tp_methods = ListMethods; +! ListType.tp_iter = ListIter; + #if PY_MAJOR_VERSION >= 3 +! ListType.tp_getattro = ListGetattro; +! ListType.tp_setattro = ListSetattro; + #else +! ListType.tp_getattr = ListGetattr; +! ListType.tp_setattr = ListSetattr; + #endif + + vim_memset(&FunctionType, 0, sizeof(FunctionType)); + FunctionType.tp_name = "vim.function"; + FunctionType.tp_basicsize = sizeof(FunctionObject); +! FunctionType.tp_dealloc = FunctionDestructor; +! FunctionType.tp_call = FunctionCall; + FunctionType.tp_flags = Py_TPFLAGS_DEFAULT; + FunctionType.tp_doc = "object that calls vim function"; + FunctionType.tp_methods = FunctionMethods; + #if PY_MAJOR_VERSION >= 3 +! FunctionType.tp_getattro = FunctionGetattro; + #else +! FunctionType.tp_getattr = FunctionGetattr; + #endif + + vim_memset(&OptionsType, 0, sizeof(OptionsType)); +--- 4108,4166 ---- + CurrentType.tp_flags = Py_TPFLAGS_DEFAULT; + CurrentType.tp_doc = "vim current object"; + #if PY_MAJOR_VERSION >= 3 +! CurrentType.tp_getattro = (getattrofunc)CurrentGetattro; +! CurrentType.tp_setattro = (setattrofunc)CurrentSetattro; + #else +! CurrentType.tp_getattr = (getattrfunc)CurrentGetattr; +! CurrentType.tp_setattr = (setattrfunc)CurrentSetattr; + #endif + + vim_memset(&DictionaryType, 0, sizeof(DictionaryType)); + DictionaryType.tp_name = "vim.dictionary"; + DictionaryType.tp_basicsize = sizeof(DictionaryObject); +! DictionaryType.tp_dealloc = (destructor)DictionaryDestructor; + DictionaryType.tp_as_mapping = &DictionaryAsMapping; + DictionaryType.tp_flags = Py_TPFLAGS_DEFAULT; + DictionaryType.tp_doc = "dictionary pushing modifications to vim structure"; + DictionaryType.tp_methods = DictionaryMethods; + #if PY_MAJOR_VERSION >= 3 +! DictionaryType.tp_getattro = (getattrofunc)DictionaryGetattro; +! DictionaryType.tp_setattro = (setattrofunc)DictionarySetattro; + #else +! DictionaryType.tp_getattr = (getattrfunc)DictionaryGetattr; +! DictionaryType.tp_setattr = (setattrfunc)DictionarySetattr; + #endif + + vim_memset(&ListType, 0, sizeof(ListType)); + ListType.tp_name = "vim.list"; +! ListType.tp_dealloc = (destructor)ListDestructor; + ListType.tp_basicsize = sizeof(ListObject); + ListType.tp_as_sequence = &ListAsSeq; + ListType.tp_as_mapping = &ListAsMapping; + ListType.tp_flags = Py_TPFLAGS_DEFAULT; + ListType.tp_doc = "list pushing modifications to vim structure"; + ListType.tp_methods = ListMethods; +! ListType.tp_iter = (getiterfunc)ListIter; + #if PY_MAJOR_VERSION >= 3 +! ListType.tp_getattro = (getattrofunc)ListGetattro; +! ListType.tp_setattro = (setattrofunc)ListSetattro; + #else +! ListType.tp_getattr = (getattrfunc)ListGetattr; +! ListType.tp_setattr = (setattrfunc)ListSetattr; + #endif + + vim_memset(&FunctionType, 0, sizeof(FunctionType)); + FunctionType.tp_name = "vim.function"; + FunctionType.tp_basicsize = sizeof(FunctionObject); +! FunctionType.tp_dealloc = (destructor)FunctionDestructor; +! FunctionType.tp_call = (ternaryfunc)FunctionCall; + FunctionType.tp_flags = Py_TPFLAGS_DEFAULT; + FunctionType.tp_doc = "object that calls vim function"; + FunctionType.tp_methods = FunctionMethods; + #if PY_MAJOR_VERSION >= 3 +! FunctionType.tp_getattro = (getattrofunc)FunctionGetattro; + #else +! FunctionType.tp_getattr = (getattrfunc)FunctionGetattr; + #endif + + vim_memset(&OptionsType, 0, sizeof(OptionsType)); +*************** +*** 4208,4216 **** + OptionsType.tp_flags = Py_TPFLAGS_DEFAULT; + OptionsType.tp_doc = "object for manipulating options"; + OptionsType.tp_as_mapping = &OptionsAsMapping; +! OptionsType.tp_dealloc = OptionsDestructor; +! OptionsType.tp_traverse = OptionsTraverse; +! OptionsType.tp_clear = OptionsClear; + + #if PY_MAJOR_VERSION >= 3 + vim_memset(&vimmodule, 0, sizeof(vimmodule)); +--- 4169,4177 ---- + OptionsType.tp_flags = Py_TPFLAGS_DEFAULT; + OptionsType.tp_doc = "object for manipulating options"; + OptionsType.tp_as_mapping = &OptionsAsMapping; +! OptionsType.tp_dealloc = (destructor)OptionsDestructor; +! OptionsType.tp_traverse = (traverseproc)OptionsTraverse; +! OptionsType.tp_clear = (inquiry)OptionsClear; + + #if PY_MAJOR_VERSION >= 3 + vim_memset(&vimmodule, 0, sizeof(vimmodule)); +*** ../vim-7.3.991/src/if_python3.c 2013-05-21 18:19:33.000000000 +0200 +--- src/if_python3.c 2013-05-21 18:22:03.000000000 +0200 +*************** +*** 68,75 **** + # define PY_SSIZE_T_CLEAN + #endif + +- static void init_structs(void); +- + /* The "surrogateescape" error handler is new in Python 3.1 */ + #if PY_VERSION_HEX >= 0x030100f0 + # define CODEC_ERROR_HANDLER "surrogateescape" +--- 68,73 ---- +*************** +*** 610,617 **** + } + #endif /* DYNAMIC_PYTHON3 */ + +- static PyObject *BufferDir(PyObject *, PyObject *); +- + static int py3initialised = 0; + + #define PYINITIALISED py3initialised +--- 608,613 ---- +*************** +*** 670,675 **** +--- 666,672 ---- + return PyType_GenericAlloc(type,nitems); + } + ++ static PyObject *BufferDir(PyObject *); + static PyObject *OutputGetattro(PyObject *, PyObject *); + static int OutputSetattro(PyObject *, PyObject *, PyObject *); + static PyObject *BufferGetattro(PyObject *, PyObject *); +*************** +*** 1008,1014 **** + { + GET_ATTR_STRING(name, nameobj); + +! return OutputSetattr(self, name, val); + } + + /***************/ +--- 1005,1011 ---- + { + GET_ATTR_STRING(name, nameobj); + +! return OutputSetattr((OutputObject *)(self), name, val); + } + + /***************/ +*************** +*** 1036,1047 **** + + #define BufferType_Check(obj) ((obj)->ob_base.ob_type == &BufferType) + +- static Py_ssize_t BufferLength(PyObject *); +- static PyObject *BufferItem(PyObject *, Py_ssize_t); + static PyObject* BufferSubscript(PyObject *self, PyObject *idx); + static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject *idx, PyObject *val); + +- + /* Line range type - Implementation functions + * -------------------------------------- + */ +--- 1033,1041 ---- +*************** +*** 1097,1103 **** + } + + static PyObject * +! BufferDir(PyObject *self UNUSED, PyObject *args UNUSED) + { + return Py_BuildValue("[sssss]", "name", "number", + "append", "mark", "range"); +--- 1091,1097 ---- + } + + static PyObject * +! BufferDir(PyObject *self UNUSED) + { + return Py_BuildValue("[sssss]", "name", "number", + "append", "mark", "range"); +*************** +*** 1111,1117 **** + if (PyLong_Check(idx)) + { + long _idx = PyLong_AsLong(idx); +! return BufferItem(self,_idx); + } else if (PySlice_Check(idx)) + { + Py_ssize_t start, stop, step, slicelen; +--- 1105,1111 ---- + if (PyLong_Check(idx)) + { + long _idx = PyLong_AsLong(idx); +! return BufferItem((BufferObject *)(self), _idx); + } else if (PySlice_Check(idx)) + { + Py_ssize_t start, stop, step, slicelen; +*************** +*** 1126,1132 **** + { + return NULL; + } +! return BufferSlice(self, start, stop); + } + else + { +--- 1120,1126 ---- + { + return NULL; + } +! return BufferSlice((BufferObject *)(self), start, stop); + } + else + { +*************** +*** 1230,1236 **** + if (PyLong_Check(idx)) + { + long _idx = PyLong_AsLong(idx); +! return RangeItem(self,_idx); + } else if (PySlice_Check(idx)) + { + Py_ssize_t start, stop, step, slicelen; +--- 1224,1230 ---- + if (PyLong_Check(idx)) + { + long _idx = PyLong_AsLong(idx); +! return RangeItem((RangeObject *)(self), _idx); + } else if (PySlice_Check(idx)) + { + Py_ssize_t start, stop, step, slicelen; +*************** +*** 1242,1248 **** + { + return NULL; + } +! return RangeSlice(self, start, stop); + } + else + { +--- 1236,1242 ---- + { + return NULL; + } +! return RangeSlice((RangeObject *)(self), start, stop); + } + else + { +*************** +*** 1323,1329 **** + { + GET_ATTR_STRING(name, nameobj); + +! return WindowSetattr(self, name, val); + } + + /* Tab page list object - Definitions +--- 1317,1323 ---- + { + GET_ATTR_STRING(name, nameobj); + +! return WindowSetattr((WindowObject *)(self), name, val); + } + + /* Tab page list object - Definitions +*************** +*** 1377,1384 **** + /* Dictionary object - Definitions + */ + +- static PyInt DictionaryLength(PyObject *); +- + static PyObject * + DictionaryGetattro(PyObject *self, PyObject *nameobj) + { +--- 1371,1376 ---- +*************** +*** 1398,1412 **** + DictionarySetattro(PyObject *self, PyObject *nameobj, PyObject *val) + { + GET_ATTR_STRING(name, nameobj); +! return DictionarySetattr(self, name, val); + } + + /* List object - Definitions + */ + +- static PyInt ListLength(PyObject *); +- static PyObject *ListItem(PyObject *, Py_ssize_t); +- + static PySequenceMethods ListAsSeq = { + (lenfunc) ListLength, /* sq_length, len(x) */ + (binaryfunc) 0, /* RangeConcat, sq_concat, x+y */ +--- 1390,1401 ---- + DictionarySetattro(PyObject *self, PyObject *nameobj, PyObject *val) + { + GET_ATTR_STRING(name, nameobj); +! return DictionarySetattr((DictionaryObject *)(self), name, val); + } + + /* List object - Definitions + */ + + static PySequenceMethods ListAsSeq = { + (lenfunc) ListLength, /* sq_length, len(x) */ + (binaryfunc) 0, /* RangeConcat, sq_concat, x+y */ +*************** +*** 1430,1450 **** + }; + + static PyObject * +! ListSubscript(PyObject *self, PyObject* idxObject) + { +! if (PyLong_Check(idxObject)) + { +! long idx = PyLong_AsLong(idxObject); +! return ListItem(self, idx); + } +! else if (PySlice_Check(idxObject)) + { + Py_ssize_t start, stop, step, slicelen; + +! if (PySlice_GetIndicesEx(idxObject, ListLength(self), &start, &stop, +! &step, &slicelen) < 0) + return NULL; +! return ListSlice(self, start, stop); + } + else + { +--- 1419,1439 ---- + }; + + static PyObject * +! ListSubscript(PyObject *self, PyObject* idx) + { +! if (PyLong_Check(idx)) + { +! long _idx = PyLong_AsLong(idx); +! return ListItem((ListObject *)(self), _idx); + } +! else if (PySlice_Check(idx)) + { + Py_ssize_t start, stop, step, slicelen; + +! if (PySlice_GetIndicesEx(idx, ListLength((ListObject *)(self)), +! &start, &stop, &step, &slicelen) < 0) + return NULL; +! return ListSlice((ListObject *)(self), start, stop); + } + else + { +*************** +*** 1454,1474 **** + } + + static Py_ssize_t +! ListAsSubscript(PyObject *self, PyObject *idxObject, PyObject *obj) + { +! if (PyLong_Check(idxObject)) + { +! long idx = PyLong_AsLong(idxObject); +! return ListAssItem(self, idx, obj); + } +! else if (PySlice_Check(idxObject)) + { + Py_ssize_t start, stop, step, slicelen; + +! if (PySlice_GetIndicesEx(idxObject, ListLength(self), &start, &stop, +! &step, &slicelen) < 0) + return -1; +! return ListAssSlice(self, start, stop, obj); + } + else + { +--- 1443,1463 ---- + } + + static Py_ssize_t +! ListAsSubscript(PyObject *self, PyObject *idx, PyObject *obj) + { +! if (PyLong_Check(idx)) + { +! long _idx = PyLong_AsLong(idx); +! return ListAssItem((ListObject *)(self), _idx, obj); + } +! else if (PySlice_Check(idx)) + { + Py_ssize_t start, stop, step, slicelen; + +! if (PySlice_GetIndicesEx(idx, ListLength((ListObject *)(self)), +! &start, &stop, &step, &slicelen) < 0) + return -1; +! return ListAssSlice((ListObject *)(self), start, stop, obj); + } + else + { +*************** +*** 1492,1498 **** + ListSetattro(PyObject *self, PyObject *nameobj, PyObject *val) + { + GET_ATTR_STRING(name, nameobj); +! return ListSetattr(self, name, val); + } + + /* Function object - Definitions +--- 1481,1487 ---- + ListSetattro(PyObject *self, PyObject *nameobj, PyObject *val) + { + GET_ATTR_STRING(name, nameobj); +! return ListSetattr((ListObject *)(self), name, val); + } + + /* Function object - Definitions +*** ../vim-7.3.991/src/if_python.c 2013-05-21 18:19:33.000000000 +0200 +--- src/if_python.c 2013-05-21 18:22:03.000000000 +0200 +*************** +*** 56,63 **** + # define PY_SSIZE_T_CLEAN + #endif + +- static void init_structs(void); +- + #define PyBytes_FromString PyString_FromString + #define PyBytes_Check PyString_Check + +--- 56,61 ---- +*************** +*** 659,674 **** + * Internal function prototypes. + */ + +- static void PythonIO_Flush(void); + static int PythonIO_Init(void); + static int PythonMod_Init(void); + +- /* Utility functions for the vim/python interface +- * ---------------------------------------------- +- */ +- +- static int SetBufferLineList(buf_T *, PyInt, PyInt, PyObject *, PyInt *); +- + + /****************************************************** + * 1. Python interpreter main program. +--- 657,665 ---- +*************** +*** 1017,1025 **** + * 3. Implementation of the Vim module for Python + */ + +- static PyObject *ConvertToPyObject(typval_T *); +- static int ConvertFromPyObject(PyObject *, typval_T *); +- + /* Window type - Implementation functions + * -------------------------------------- + */ +--- 1008,1013 ---- +*** ../vim-7.3.991/src/version.c 2013-05-21 18:19:33.000000000 +0200 +--- src/version.c 2013-05-21 18:28:18.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 992, + /**/ + +-- +We apologise again for the fault in the subtitles. Those responsible for +sacking the people who have just been sacked have been sacked. + "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/7.3.993 b/7.3.993 new file mode 100644 index 00000000..d9dcbb37 --- /dev/null +++ b/7.3.993 @@ -0,0 +1,248 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.993 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.993 +Problem: Python: Later patch does things slightly differently. +Solution: Adjusted argument type changes. (ZyX) +Files: src/if_py_both.h, src/if_python3.c, src/if_python.c + + +*** ../vim-7.3.992/src/if_py_both.h 2013-05-21 18:30:29.000000000 +0200 +--- src/if_py_both.h 2013-05-21 18:42:28.000000000 +0200 +*************** +*** 220,226 **** + } + + static PyObject * +! OutputFlush(PyObject *self UNUSED) + { + /* do nothing */ + Py_INCREF(Py_None); +--- 220,226 ---- + } + + static PyObject * +! OutputFlush(PyObject *self UNUSED, PyObject *args UNUSED) + { + /* do nothing */ + Py_INCREF(Py_None); +*************** +*** 230,240 **** + /***************/ + + static struct PyMethodDef OutputMethods[] = { +! /* name, function, calling, doc */ +! {"write", (PyCFunction)OutputWrite, METH_VARARGS, ""}, +! {"writelines", (PyCFunction)OutputWritelines, METH_VARARGS, ""}, +! {"flush", (PyCFunction)OutputFlush, METH_NOARGS, ""}, +! { NULL, NULL, 0, NULL} + }; + + static OutputObject Output = +--- 230,240 ---- + /***************/ + + static struct PyMethodDef OutputMethods[] = { +! /* name, function, calling, doc */ +! {"write", (PyCFunction)OutputWrite, 1, ""}, +! {"writelines", (PyCFunction)OutputWritelines, 1, ""}, +! {"flush", (PyCFunction)OutputFlush, 1, ""}, +! { NULL, NULL, 0, NULL} + }; + + static OutputObject Output = +*************** +*** 533,544 **** + */ + + static struct PyMethodDef VimMethods[] = { +! /* name, function, calling, documentation */ +! {"command", VimCommand, METH_VARARGS, "Execute a Vim ex-mode command" }, +! {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" }, +! {"bindeval", VimEvalPy, METH_VARARGS, "Like eval(), but returns objects attached to vim ones"}, +! {"strwidth", VimStrwidth, METH_VARARGS, "Screen string width, counts as having width 1"}, +! { NULL, NULL, 0, NULL } + }; + + /* +--- 533,544 ---- + */ + + static struct PyMethodDef VimMethods[] = { +! /* name, function, calling, documentation */ +! {"command", VimCommand, 1, "Execute a Vim ex-mode command" }, +! {"eval", VimEval, 1, "Evaluate an expression using Vim evaluator" }, +! {"bindeval", VimEvalPy, 1, "Like eval(), but returns objects attached to vim ones"}, +! {"strwidth", VimStrwidth, 1, "Screen string width, counts as having width 1"}, +! { NULL, NULL, 0, NULL } + }; + + /* +*************** +*** 868,875 **** + }; + + static struct PyMethodDef DictionaryMethods[] = { +! {"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""}, +! { NULL, NULL, 0, NULL } + }; + + static PyTypeObject ListType; +--- 868,875 ---- + }; + + static struct PyMethodDef DictionaryMethods[] = { +! {"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""}, +! { NULL, NULL, 0, NULL } + }; + + static PyTypeObject ListType; +*************** +*** 1248,1255 **** + } + + static struct PyMethodDef ListMethods[] = { +! {"extend", (PyCFunction)ListConcatInPlace, METH_O, ""}, +! { NULL, NULL, 0, NULL } + }; + + typedef struct +--- 1248,1255 ---- + } + + static struct PyMethodDef ListMethods[] = { +! {"extend", (PyCFunction)ListConcatInPlace, METH_O, ""}, +! { NULL, NULL, 0, NULL } + }; + + typedef struct +*************** +*** 1349,1356 **** + } + + static struct PyMethodDef FunctionMethods[] = { +! {"__call__", (PyCFunction)FunctionCall, METH_VARARGS|METH_KEYWORDS, ""}, +! { NULL, NULL, 0, NULL} + }; + + /* +--- 1349,1356 ---- + } + + static struct PyMethodDef FunctionMethods[] = { +! {"__call__", (PyCFunction)FunctionCall, METH_VARARGS|METH_KEYWORDS, ""}, +! { NULL, NULL, 0, NULL } + }; + + /* +*************** +*** 2960,2968 **** + } + + static struct PyMethodDef RangeMethods[] = { +! /* name, function, calling, documentation */ +! {"append", (PyCFunction)RangeAppend, METH_VARARGS, "Append data to the Vim range" }, +! { NULL, NULL, 0, NULL } + }; + + static PyTypeObject BufferType; +--- 2960,2968 ---- + } + + static struct PyMethodDef RangeMethods[] = { +! /* name, function, calling, documentation */ +! {"append", (PyCFunction)RangeAppend, 1, "Append data to the Vim range" }, +! { NULL, NULL, 0, NULL } + }; + + static PyTypeObject BufferType; +*************** +*** 3146,3159 **** + } + + static struct PyMethodDef BufferMethods[] = { +! /* name, function, calling, documentation */ +! {"append", (PyCFunction)BufferAppend, METH_VARARGS, "Append data to Vim buffer" }, +! {"mark", (PyCFunction)BufferMark, METH_VARARGS, "Return (row,col) representing position of named mark" }, +! {"range", (PyCFunction)BufferRange, METH_VARARGS, "Return a range object which represents the part of the given buffer between line numbers s and e" }, + #if PY_VERSION_HEX >= 0x03000000 +! {"__dir__", (PyCFunction)BufferDir, METH_NOARGS, "List buffer attributes" }, + #endif +! { NULL, NULL, 0, NULL } + }; + + /* +--- 3146,3159 ---- + } + + static struct PyMethodDef BufferMethods[] = { +! /* name, function, calling, documentation */ +! {"append", (PyCFunction)BufferAppend, 1, "Append data to Vim buffer" }, +! {"mark", (PyCFunction)BufferMark, 1, "Return (row,col) representing position of named mark" }, +! {"range", (PyCFunction)BufferRange, 1, "Return a range object which represents the part of the given buffer between line numbers s and e" }, + #if PY_VERSION_HEX >= 0x03000000 +! {"__dir__", (PyCFunction)BufferDir, 4, "List its attributes" }, + #endif +! { NULL, NULL, 0, NULL } + }; + + /* +*** ../vim-7.3.992/src/if_python3.c 2013-05-21 18:30:29.000000000 +0200 +--- src/if_python3.c 2013-05-21 18:42:28.000000000 +0200 +*************** +*** 666,672 **** + return PyType_GenericAlloc(type,nitems); + } + +! static PyObject *BufferDir(PyObject *); + static PyObject *OutputGetattro(PyObject *, PyObject *); + static int OutputSetattro(PyObject *, PyObject *, PyObject *); + static PyObject *BufferGetattro(PyObject *, PyObject *); +--- 666,672 ---- + return PyType_GenericAlloc(type,nitems); + } + +! static PyObject *BufferDir(PyObject *, PyObject *); + static PyObject *OutputGetattro(PyObject *, PyObject *); + static int OutputSetattro(PyObject *, PyObject *, PyObject *); + static PyObject *BufferGetattro(PyObject *, PyObject *); +*************** +*** 1091,1097 **** + } + + static PyObject * +! BufferDir(PyObject *self UNUSED) + { + return Py_BuildValue("[sssss]", "name", "number", + "append", "mark", "range"); +--- 1091,1097 ---- + } + + static PyObject * +! BufferDir(PyObject *self UNUSED, PyObject *args UNUSED) + { + return Py_BuildValue("[sssss]", "name", "number", + "append", "mark", "range"); +*** ../vim-7.3.992/src/version.c 2013-05-21 18:30:29.000000000 +0200 +--- src/version.c 2013-05-21 18:46:51.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 993, + /**/ + +-- +How come wrong numbers are never busy? + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/7.3.994 b/7.3.994 new file mode 100644 index 00000000..221ec102 --- /dev/null +++ b/7.3.994 @@ -0,0 +1,249 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.994 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.994 +Problem: Python: using magic constants. +Solution: Use descriptive values for ml_flags. (ZyX) +Files: src/if_py_both.h, src/if_python3.c + + +*** ../vim-7.3.993/src/if_py_both.h 2013-05-21 18:47:17.000000000 +0200 +--- src/if_py_both.h 2013-05-21 18:51:12.000000000 +0200 +*************** +*** 220,226 **** + } + + static PyObject * +! OutputFlush(PyObject *self UNUSED, PyObject *args UNUSED) + { + /* do nothing */ + Py_INCREF(Py_None); +--- 220,226 ---- + } + + static PyObject * +! OutputFlush(PyObject *self UNUSED) + { + /* do nothing */ + Py_INCREF(Py_None); +*************** +*** 230,240 **** + /***************/ + + static struct PyMethodDef OutputMethods[] = { +! /* name, function, calling, doc */ +! {"write", (PyCFunction)OutputWrite, 1, ""}, +! {"writelines", (PyCFunction)OutputWritelines, 1, ""}, +! {"flush", (PyCFunction)OutputFlush, 1, ""}, +! { NULL, NULL, 0, NULL} + }; + + static OutputObject Output = +--- 230,240 ---- + /***************/ + + static struct PyMethodDef OutputMethods[] = { +! /* name, function, calling, doc */ +! {"write", (PyCFunction)OutputWrite, METH_VARARGS, ""}, +! {"writelines", (PyCFunction)OutputWritelines, METH_VARARGS, ""}, +! {"flush", (PyCFunction)OutputFlush, METH_NOARGS, ""}, +! { NULL, NULL, 0, NULL} + }; + + static OutputObject Output = +*************** +*** 533,544 **** + */ + + static struct PyMethodDef VimMethods[] = { +! /* name, function, calling, documentation */ +! {"command", VimCommand, 1, "Execute a Vim ex-mode command" }, +! {"eval", VimEval, 1, "Evaluate an expression using Vim evaluator" }, +! {"bindeval", VimEvalPy, 1, "Like eval(), but returns objects attached to vim ones"}, +! {"strwidth", VimStrwidth, 1, "Screen string width, counts as having width 1"}, +! { NULL, NULL, 0, NULL } + }; + + /* +--- 533,544 ---- + */ + + static struct PyMethodDef VimMethods[] = { +! /* name, function, calling, documentation */ +! {"command", VimCommand, METH_VARARGS, "Execute a Vim ex-mode command" }, +! {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" }, +! {"bindeval", VimEvalPy, METH_VARARGS, "Like eval(), but returns objects attached to vim ones"}, +! {"strwidth", VimStrwidth, METH_VARARGS, "Screen string width, counts as having width 1"}, +! { NULL, NULL, 0, NULL } + }; + + /* +*************** +*** 868,875 **** + }; + + static struct PyMethodDef DictionaryMethods[] = { +! {"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""}, +! { NULL, NULL, 0, NULL } + }; + + static PyTypeObject ListType; +--- 868,875 ---- + }; + + static struct PyMethodDef DictionaryMethods[] = { +! {"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""}, +! { NULL, NULL, 0, NULL } + }; + + static PyTypeObject ListType; +*************** +*** 1248,1255 **** + } + + static struct PyMethodDef ListMethods[] = { +! {"extend", (PyCFunction)ListConcatInPlace, METH_O, ""}, +! { NULL, NULL, 0, NULL } + }; + + typedef struct +--- 1248,1255 ---- + } + + static struct PyMethodDef ListMethods[] = { +! {"extend", (PyCFunction)ListConcatInPlace, METH_O, ""}, +! { NULL, NULL, 0, NULL } + }; + + typedef struct +*************** +*** 1349,1356 **** + } + + static struct PyMethodDef FunctionMethods[] = { +! {"__call__", (PyCFunction)FunctionCall, METH_VARARGS|METH_KEYWORDS, ""}, +! { NULL, NULL, 0, NULL } + }; + + /* +--- 1349,1356 ---- + } + + static struct PyMethodDef FunctionMethods[] = { +! {"__call__", (PyCFunction)FunctionCall, METH_VARARGS|METH_KEYWORDS, ""}, +! { NULL, NULL, 0, NULL} + }; + + /* +*************** +*** 2960,2968 **** + } + + static struct PyMethodDef RangeMethods[] = { +! /* name, function, calling, documentation */ +! {"append", (PyCFunction)RangeAppend, 1, "Append data to the Vim range" }, +! { NULL, NULL, 0, NULL } + }; + + static PyTypeObject BufferType; +--- 2960,2968 ---- + } + + static struct PyMethodDef RangeMethods[] = { +! /* name, function, calling, documentation */ +! {"append", (PyCFunction)RangeAppend, METH_VARARGS, "Append data to the Vim range" }, +! { NULL, NULL, 0, NULL } + }; + + static PyTypeObject BufferType; +*************** +*** 3146,3159 **** + } + + static struct PyMethodDef BufferMethods[] = { +! /* name, function, calling, documentation */ +! {"append", (PyCFunction)BufferAppend, 1, "Append data to Vim buffer" }, +! {"mark", (PyCFunction)BufferMark, 1, "Return (row,col) representing position of named mark" }, +! {"range", (PyCFunction)BufferRange, 1, "Return a range object which represents the part of the given buffer between line numbers s and e" }, + #if PY_VERSION_HEX >= 0x03000000 +! {"__dir__", (PyCFunction)BufferDir, 4, "List its attributes" }, + #endif +! { NULL, NULL, 0, NULL } + }; + + /* +--- 3146,3159 ---- + } + + static struct PyMethodDef BufferMethods[] = { +! /* name, function, calling, documentation */ +! {"append", (PyCFunction)BufferAppend, METH_VARARGS, "Append data to Vim buffer" }, +! {"mark", (PyCFunction)BufferMark, METH_VARARGS, "Return (row,col) representing position of named mark" }, +! {"range", (PyCFunction)BufferRange, METH_VARARGS, "Return a range object which represents the part of the given buffer between line numbers s and e" }, + #if PY_VERSION_HEX >= 0x03000000 +! {"__dir__", (PyCFunction)BufferDir, METH_NOARGS, "List buffer attributes" }, + #endif +! { NULL, NULL, 0, NULL } + }; + + /* +*** ../vim-7.3.993/src/if_python3.c 2013-05-21 18:47:17.000000000 +0200 +--- src/if_python3.c 2013-05-21 18:51:12.000000000 +0200 +*************** +*** 666,672 **** + return PyType_GenericAlloc(type,nitems); + } + +! static PyObject *BufferDir(PyObject *, PyObject *); + static PyObject *OutputGetattro(PyObject *, PyObject *); + static int OutputSetattro(PyObject *, PyObject *, PyObject *); + static PyObject *BufferGetattro(PyObject *, PyObject *); +--- 666,672 ---- + return PyType_GenericAlloc(type,nitems); + } + +! static PyObject *BufferDir(PyObject *); + static PyObject *OutputGetattro(PyObject *, PyObject *); + static int OutputSetattro(PyObject *, PyObject *, PyObject *); + static PyObject *BufferGetattro(PyObject *, PyObject *); +*************** +*** 1091,1097 **** + } + + static PyObject * +! BufferDir(PyObject *self UNUSED, PyObject *args UNUSED) + { + return Py_BuildValue("[sssss]", "name", "number", + "append", "mark", "range"); +--- 1091,1097 ---- + } + + static PyObject * +! BufferDir(PyObject *self UNUSED) + { + return Py_BuildValue("[sssss]", "name", "number", + "append", "mark", "range"); +*** ../vim-7.3.993/src/version.c 2013-05-21 18:47:17.000000000 +0200 +--- src/version.c 2013-05-21 18:51:33.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 994, + /**/ + +-- +It might look like I'm doing nothing, but at the cellular level +I'm really quite busy. + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/7.3.995 b/7.3.995 new file mode 100644 index 00000000..daa01bee --- /dev/null +++ b/7.3.995 @@ -0,0 +1,512 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.995 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.995 +Problem: Python: Module initialization is duplicated. +Solution: Move to shared file. (ZyX) +Files: src/if_py_both.h, src/if_python3.c, src/if_python.c + + +*** ../vim-7.3.994/src/if_py_both.h 2013-05-21 19:01:51.000000000 +0200 +--- src/if_py_both.h 2013-05-21 19:07:17.000000000 +0200 +*************** +*** 4181,4183 **** +--- 4181,4295 ---- + vimmodule.m_methods = VimMethods; + #endif + } ++ ++ #define PYTYPE_READY(type) \ ++ if (PyType_Ready(&type)) \ ++ return -1; ++ ++ static int ++ init_types() ++ { ++ PYTYPE_READY(IterType); ++ PYTYPE_READY(BufferType); ++ PYTYPE_READY(RangeType); ++ PYTYPE_READY(WindowType); ++ PYTYPE_READY(TabPageType); ++ PYTYPE_READY(BufMapType); ++ PYTYPE_READY(WinListType); ++ PYTYPE_READY(TabListType); ++ PYTYPE_READY(CurrentType); ++ PYTYPE_READY(DictionaryType); ++ PYTYPE_READY(ListType); ++ PYTYPE_READY(FunctionType); ++ PYTYPE_READY(OptionsType); ++ PYTYPE_READY(OutputType); ++ return 0; ++ } ++ ++ static BufMapObject TheBufferMap = ++ { ++ PyObject_HEAD_INIT(&BufMapType) ++ }; ++ ++ static WinListObject TheWindowList = ++ { ++ PyObject_HEAD_INIT(&WinListType) ++ NULL ++ }; ++ ++ static CurrentObject TheCurrent = ++ { ++ PyObject_HEAD_INIT(&CurrentType) ++ }; ++ ++ static TabListObject TheTabPageList = ++ { ++ PyObject_HEAD_INIT(&TabListType) ++ }; ++ ++ static struct numeric_constant { ++ char *name; ++ int value; ++ } numeric_constants[] = { ++ {"VAR_LOCKED", VAR_LOCKED}, ++ {"VAR_FIXED", VAR_FIXED}, ++ {"VAR_SCOPE", VAR_SCOPE}, ++ {"VAR_DEF_SCOPE", VAR_DEF_SCOPE}, ++ }; ++ ++ static struct object_constant { ++ char *name; ++ PyObject *value; ++ } object_constants[] = { ++ {"buffers", (PyObject *)(void *)&TheBufferMap}, ++ {"windows", (PyObject *)(void *)&TheWindowList}, ++ {"tabpages", (PyObject *)(void *)&TheTabPageList}, ++ {"current", (PyObject *)(void *)&TheCurrent}, ++ }; ++ ++ typedef int (*object_adder)(PyObject *, const char *, PyObject *); ++ ++ #define ADD_OBJECT(m, name, obj) \ ++ if (add_object(m, name, obj)) \ ++ return -1; ++ ++ #define ADD_CHECKED_OBJECT(m, name, obj) \ ++ { \ ++ PyObject *value = obj; \ ++ if (!value) \ ++ return -1; \ ++ ADD_OBJECT(m, name, value); \ ++ } ++ ++ static int ++ populate_module(PyObject *m, object_adder add_object) ++ { ++ int i; ++ ++ for (i = 0; i < (int)(sizeof(numeric_constants) ++ / sizeof(struct numeric_constant)); ++ ++i) ++ ADD_CHECKED_OBJECT(m, numeric_constants[i].name, ++ PyInt_FromLong(numeric_constants[i].value)); ++ ++ for (i = 0; i < (int)(sizeof(object_constants) ++ / sizeof(struct object_constant)); ++ ++i) ++ { ++ PyObject *value; ++ ++ value = object_constants[i].value; ++ Py_INCREF(value); ++ ADD_OBJECT(m, object_constants[i].name, value); ++ } ++ ++ if (!(VimError = PyErr_NewException("vim.error", NULL, NULL))) ++ return -1; ++ ADD_OBJECT(m, "error", VimError); ++ ++ ADD_CHECKED_OBJECT(m, "vars", DictionaryNew(&globvardict)); ++ ADD_CHECKED_OBJECT(m, "vvars", DictionaryNew(&vimvardict)); ++ ADD_CHECKED_OBJECT(m, "options", ++ OptionsNew(SREQ_GLOBAL, NULL, dummy_check, NULL)); ++ return 0; ++ } +*** ../vim-7.3.994/src/if_python3.c 2013-05-21 19:01:51.000000000 +0200 +--- src/if_python3.c 2013-05-21 19:07:40.000000000 +0200 +*************** +*** 700,706 **** + * Internal function prototypes. + */ + +- static int PythonIO_Init(void); + static PyObject *Py3Init_vim(void); + + /****************************************************** +--- 700,705 ---- +*************** +*** 780,786 **** + get_py3_exceptions(); + #endif + +! if (PythonIO_Init()) + goto fail; + + globals = PyModule_GetDict(PyImport_AddModule("__main__")); +--- 779,785 ---- + get_py3_exceptions(); + #endif + +! if (PythonIO_Init_io()) + goto fail; + + globals = PyModule_GetDict(PyImport_AddModule("__main__")); +*************** +*** 811,817 **** + fail: + /* We call PythonIO_Flush() here to print any Python errors. + * This is OK, as it is possible to call this function even +! * if PythonIO_Init() has not completed successfully (it will + * not do anything in this case). + */ + PythonIO_Flush(); +--- 810,816 ---- + fail: + /* We call PythonIO_Flush() here to print any Python errors. + * This is OK, as it is possible to call this function even +! * if PythonIO_Init_io() has not completed successfully (it will + * not do anything in this case). + */ + PythonIO_Flush(); +*************** +*** 1008,1022 **** + return OutputSetattr((OutputObject *)(self), name, val); + } + +- /***************/ +- +- static int +- PythonIO_Init(void) +- { +- PyType_Ready(&OutputType); +- return PythonIO_Init_io(); +- } +- + /****************************************************** + * 3. Implementation of the Vim module for Python + */ +--- 1007,1012 ---- +*************** +*** 1538,1585 **** + } + #endif + +- static BufMapObject TheBufferMap = +- { +- PyObject_HEAD_INIT(&BufMapType) +- }; +- +- static WinListObject TheWindowList = +- { +- PyObject_HEAD_INIT(&WinListType) +- NULL +- }; +- +- static CurrentObject TheCurrent = +- { +- PyObject_HEAD_INIT(&CurrentType) +- }; +- +- static TabListObject TheTabPageList = +- { +- PyObject_HEAD_INIT(&TabListType) +- }; +- + static PyObject * + Py3Init_vim(void) + { + PyObject *mod; +! PyObject *tmp; + /* The special value is removed from sys.path in Python3_Init(). */ + static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL}; + +! PyType_Ready(&IterType); +! PyType_Ready(&BufferType); +! PyType_Ready(&RangeType); +! PyType_Ready(&WindowType); +! PyType_Ready(&TabPageType); +! PyType_Ready(&BufMapType); +! PyType_Ready(&WinListType); +! PyType_Ready(&TabListType); +! PyType_Ready(&CurrentType); +! PyType_Ready(&DictionaryType); +! PyType_Ready(&ListType); +! PyType_Ready(&FunctionType); +! PyType_Ready(&OptionsType); + + /* Set sys.argv[] to avoid a crash in warn(). */ + PySys_SetArgv(1, argv); +--- 1528,1543 ---- + } + #endif + + static PyObject * + Py3Init_vim(void) + { + PyObject *mod; +! + /* The special value is removed from sys.path in Python3_Init(). */ + static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL}; + +! if (init_types()) +! return NULL; + + /* Set sys.argv[] to avoid a crash in warn(). */ + PySys_SetArgv(1, argv); +*************** +*** 1588,1622 **** + if (mod == NULL) + return NULL; + +! VimError = PyErr_NewException("vim.error", NULL, NULL); +! +! Py_INCREF(VimError); +! PyModule_AddObject(mod, "error", VimError); +! Py_INCREF((PyObject *)(void *)&TheBufferMap); +! PyModule_AddObject(mod, "buffers", (PyObject *)(void *)&TheBufferMap); +! Py_INCREF((PyObject *)(void *)&TheCurrent); +! PyModule_AddObject(mod, "current", (PyObject *)(void *)&TheCurrent); +! Py_INCREF((PyObject *)(void *)&TheWindowList); +! PyModule_AddObject(mod, "windows", (PyObject *)(void *)&TheWindowList); +! Py_INCREF((PyObject *)(void *)&TheTabPageList); +! PyModule_AddObject(mod, "tabpages", (PyObject *)(void *)&TheTabPageList); +! +! PyModule_AddObject(mod, "vars", DictionaryNew(&globvardict)); +! PyModule_AddObject(mod, "vvars", DictionaryNew(&vimvardict)); +! PyModule_AddObject(mod, "options", +! OptionsNew(SREQ_GLOBAL, NULL, dummy_check, NULL)); +! +! #define ADD_INT_CONSTANT(name, value) \ +! tmp = PyLong_FromLong(value); \ +! Py_INCREF(tmp); \ +! PyModule_AddObject(mod, name, tmp) +! +! ADD_INT_CONSTANT("VAR_LOCKED", VAR_LOCKED); +! ADD_INT_CONSTANT("VAR_FIXED", VAR_FIXED); +! ADD_INT_CONSTANT("VAR_SCOPE", VAR_SCOPE); +! ADD_INT_CONSTANT("VAR_DEF_SCOPE", VAR_DEF_SCOPE); +! +! if (PyErr_Occurred()) + return NULL; + + return mod; +--- 1546,1552 ---- + if (mod == NULL) + return NULL; + +! if (populate_module(mod, PyModule_AddObject)) + return NULL; + + return mod; +*** ../vim-7.3.994/src/if_python.c 2013-05-21 18:30:29.000000000 +0200 +--- src/if_python.c 2013-05-21 19:07:26.000000000 +0200 +*************** +*** 657,663 **** + * Internal function prototypes. + */ + +- static int PythonIO_Init(void); + static int PythonMod_Init(void); + + +--- 657,662 ---- +*************** +*** 772,778 **** + get_exceptions(); + #endif + +! if (PythonIO_Init()) + goto fail; + + if (PythonMod_Init()) +--- 771,777 ---- + get_exceptions(); + #endif + +! if (PythonIO_Init_io()) + goto fail; + + if (PythonMod_Init()) +*************** +*** 806,812 **** + fail: + /* We call PythonIO_Flush() here to print any Python errors. + * This is OK, as it is possible to call this function even +! * if PythonIO_Init() has not completed successfully (it will + * not do anything in this case). + */ + PythonIO_Flush(); +--- 805,811 ---- + fail: + /* We call PythonIO_Flush() here to print any Python errors. + * This is OK, as it is possible to call this function even +! * if PythonIO_Init_io() has not completed successfully (it will + * not do anything in this case). + */ + PythonIO_Flush(); +*************** +*** 993,1009 **** + return Py_FindMethod(OutputMethods, self, name); + } + +- /***************/ +- +- static int +- PythonIO_Init(void) +- { +- /* Fixups... */ +- PyType_Ready(&OutputType); +- +- return PythonIO_Init_io(); +- } +- + /****************************************************** + * 3. Implementation of the Vim module for Python + */ +--- 992,997 ---- +*************** +*** 1242,1288 **** + } + #endif + +! static BufMapObject TheBufferMap = +! { +! PyObject_HEAD_INIT(&BufMapType) +! }; +! +! static WinListObject TheWindowList = +! { +! PyObject_HEAD_INIT(&WinListType) +! NULL +! }; +! +! static CurrentObject TheCurrent = +! { +! PyObject_HEAD_INIT(&CurrentType) +! }; +! +! static TabListObject TheTabPageList = + { +! PyObject_HEAD_INIT(&TabListType) +! }; + + static int + PythonMod_Init(void) + { + PyObject *mod; + PyObject *dict; +! PyObject *tmp; + /* The special value is removed from sys.path in Python_Init(). */ + static char *(argv[2]) = {"/must>not&exist/foo", NULL}; + +! /* Fixups... */ +! PyType_Ready(&IterType); +! PyType_Ready(&BufferType); +! PyType_Ready(&RangeType); +! PyType_Ready(&WindowType); +! PyType_Ready(&TabPageType); +! PyType_Ready(&BufMapType); +! PyType_Ready(&WinListType); +! PyType_Ready(&TabListType); +! PyType_Ready(&CurrentType); +! PyType_Ready(&OptionsType); + + /* Set sys.argv[] to avoid a crash in warn(). */ + PySys_SetArgv(1, argv); +--- 1230,1255 ---- + } + #endif + +! static int +! add_object(PyObject *dict, const char *name, PyObject *object) + { +! if (PyDict_SetItemString(dict, (char *) name, object)) +! return -1; +! Py_DECREF(object); +! return 0; +! } + + static int + PythonMod_Init(void) + { + PyObject *mod; + PyObject *dict; +! + /* The special value is removed from sys.path in Python_Init(). */ + static char *(argv[2]) = {"/must>not&exist/foo", NULL}; + +! if (init_types()) +! return -1; + + /* Set sys.argv[] to avoid a crash in warn(). */ + PySys_SetArgv(1, argv); +*************** +*** 1290,1320 **** + mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL, PYTHON_API_VERSION); + dict = PyModule_GetDict(mod); + +! VimError = PyErr_NewException("vim.error", NULL, NULL); +! +! PyDict_SetItemString(dict, "error", VimError); +! PyDict_SetItemString(dict, "buffers", (PyObject *)(void *)&TheBufferMap); +! PyDict_SetItemString(dict, "current", (PyObject *)(void *)&TheCurrent); +! PyDict_SetItemString(dict, "windows", (PyObject *)(void *)&TheWindowList); +! PyDict_SetItemString(dict, "tabpages", (PyObject *)(void *)&TheTabPageList); +! tmp = DictionaryNew(&globvardict); +! PyDict_SetItemString(dict, "vars", tmp); +! Py_DECREF(tmp); +! tmp = DictionaryNew(&vimvardict); +! PyDict_SetItemString(dict, "vvars", tmp); +! Py_DECREF(tmp); +! tmp = OptionsNew(SREQ_GLOBAL, NULL, dummy_check, NULL); +! PyDict_SetItemString(dict, "options", tmp); +! Py_DECREF(tmp); +! PyDict_SetItemString(dict, "VAR_LOCKED", PyInt_FromLong(VAR_LOCKED)); +! PyDict_SetItemString(dict, "VAR_FIXED", PyInt_FromLong(VAR_FIXED)); +! PyDict_SetItemString(dict, "VAR_SCOPE", PyInt_FromLong(VAR_SCOPE)); +! PyDict_SetItemString(dict, "VAR_DEF_SCOPE", PyInt_FromLong(VAR_DEF_SCOPE)); +! +! if (PyErr_Occurred()) +! return -1; +! +! return 0; + } + + /************************************************************************* +--- 1257,1263 ---- + mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL, PYTHON_API_VERSION); + dict = PyModule_GetDict(mod); + +! return populate_module(dict, add_object); + } + + /************************************************************************* +*** ../vim-7.3.994/src/version.c 2013-05-21 19:01:51.000000000 +0200 +--- src/version.c 2013-05-21 19:06:22.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 995, + /**/ + +-- +System administrators are just like women: You can't live with them and you +can't live without them. + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/7.3.996 b/7.3.996 new file mode 100644 index 00000000..284fce9b --- /dev/null +++ b/7.3.996 @@ -0,0 +1,374 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.996 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.996 +Problem: Python: Can't check types of what is returned by bindeval(). +Solution: Add vim.List, vim.Dictionary and vim.Function types. (ZyX) +Files: runtime/doc/if_pyth.txt, src/if_py_both.h, src/testdir/test86.in, + src/testdir/test86.ok, src/testdir/test87.in, + src/testdir/test87.ok + + +*** ../vim-7.3.995/runtime/doc/if_pyth.txt 2013-05-17 16:39:59.000000000 +0200 +--- runtime/doc/if_pyth.txt 2013-05-21 19:21:58.000000000 +0200 +*************** +*** 11,19 **** + 3. Buffer objects |python-buffer| + 4. Range objects |python-range| + 5. Window objects |python-window| +! 6. pyeval(), py3eval() Vim functions |python-pyeval| +! 7. Dynamic loading |python-dynamic| +! 8. Python 3 |python3| + + {Vi does not have any of these commands} + +--- 11,20 ---- + 3. Buffer objects |python-buffer| + 4. Range objects |python-range| + 5. Window objects |python-window| +! 6. Tab page objects |python-tabpage| +! 7. pyeval(), py3eval() Vim functions |python-pyeval| +! 8. Dynamic loading |python-dynamic| +! 9. Python 3 |python3| + + {Vi does not have any of these commands} + +*************** +*** 176,182 **** + list or dictionary. Thus modifications to these objects imply + modifications of the original. + +! Additionally, vimlist and vimdictionary type have read-write + `.locked` attribute that returns + Value Meaning ~ + zero Variable is not locked +--- 177,183 ---- + list or dictionary. Thus modifications to these objects imply + modifications of the original. + +! Additionally, vim.List and vim.Dictionary type have read-write + `.locked` attribute that returns + Value Meaning ~ + zero Variable is not locked +*************** +*** 189,202 **** + case these locks are ignored by anything except |:let|: |extend()| + does not care, neither does python interface). + +! Vimdictionary type also supports `.scope` attribute which is one of + Value Meaning ~ + zero Dictionary is not a scope one + vim.VAR_DEF_SCOPE Function-local or global scope dictionary + vim.VAR_SCOPE Other scope dictionary + + 2. if expression evaluates to a function reference, then it returns +! callable vimfunction object. Use self keyword argument to assign + |self| object for dictionary functions. + + Note: this function has the same behavior as |lua-eval| (except that +--- 190,204 ---- + case these locks are ignored by anything except |:let|: |extend()| + does not care, neither does python interface). + +! vim.Dictionary type also supports `.scope` attribute which is one +! of + Value Meaning ~ + zero Dictionary is not a scope one + vim.VAR_DEF_SCOPE Function-local or global scope dictionary + vim.VAR_SCOPE Other scope dictionary + + 2. if expression evaluates to a function reference, then it returns +! callable vim.Function object. Use self keyword argument to assign + |self| object for dictionary functions. + + Note: this function has the same behavior as |lua-eval| (except that +*************** +*** 205,210 **** +--- 207,216 ---- + relying on outputs of vim.eval() being a copy of original or + vim.eval("1") returning a string. + ++ You can use "List", "Dictionary" and "Function" vim module attributes ++ to test whether object has given type. These types are currently not ++ subclassable, neither they contain constructors, so you can use them ++ only for checks like `isinstance(obj, vim.List)`. + + + Error object of the "vim" module +*************** +*** 302,307 **** +--- 308,316 ---- + buffer-local options and |python-window| objects to access to + window-local options. + ++ Type of this object is available via "Options" attribute of vim ++ module. ++ + Output from Python *python-output* + Vim displays all Python code output in the Vim message area. Normal + output appears as information messages, and error output appears as +*************** +*** 371,376 **** +--- 380,387 ---- + A trailing '\n' is allowed and ignored, so that you can do: > + :py b.append(f.readlines()) + ++ Buffer object type is available using "Buffer" attribute of vim module. ++ + Examples (assume b is the current buffer) > + :py print b.name # write the buffer file name + :py b[0] = "hello!!!" # replace the top line +*************** +*** 412,417 **** +--- 423,430 ---- + for Python's built-in list objects. + r.append(list, nr) Idem, after line "nr" + ++ Range object type is available using "Range" attribute of vim module. ++ + Example (assume r is the current range): + # Send all lines in a range to the default printer + vim.command("%d,%dhardcopy!" % (r.start+1,r.end+1)) +*************** +*** 456,461 **** +--- 469,476 ---- + The height attribute is writable only if the screen is split horizontally. + The width attribute is writable only if the screen is split vertically. + ++ Window object type is available using "Window" attribute of vim module. ++ + ============================================================================== + 6. Tab page objects *python-tabpage* + +*************** +*** 474,487 **** + vars The tab page |t:| variables. + window Current tabpage window. + + ============================================================================== +! 6. pyeval() and py3eval() Vim functions *python-pyeval* + + To facilitate bi-directional interface, you can use |pyeval()| and |py3eval()| + functions to evaluate Python expressions and pass their values to VimL. + + ============================================================================== +! 7. Dynamic loading *python-dynamic* + + On MS-Windows the Python library can be loaded dynamically. The |:version| + output then includes |+python/dyn|. +--- 489,504 ---- + vars The tab page |t:| variables. + window Current tabpage window. + ++ TabPage object type is available using "TabPage" attribute of vim module. ++ + ============================================================================== +! 7. pyeval() and py3eval() Vim functions *python-pyeval* + + To facilitate bi-directional interface, you can use |pyeval()| and |py3eval()| + functions to evaluate Python expressions and pass their values to VimL. + + ============================================================================== +! 8. Dynamic loading *python-dynamic* + + On MS-Windows the Python library can be loaded dynamically. The |:version| + output then includes |+python/dyn|. +*************** +*** 498,504 **** + sure edit "gvim.exe" and search for "python\d*.dll\c". + + ============================================================================== +! 8. Python 3 *python3* + + *:py3* *:python3* + The `:py3` and `:python3` commands work similar to `:python`. A simple check +--- 515,521 ---- + sure edit "gvim.exe" and search for "python\d*.dll\c". + + ============================================================================== +! 9. Python 3 *python3* + + *:py3* *:python3* + The `:py3` and `:python3` commands work similar to `:python`. A simple check +*** ../vim-7.3.995/src/if_py_both.h 2013-05-21 19:10:56.000000000 +0200 +--- src/if_py_both.h 2013-05-21 19:21:58.000000000 +0200 +*************** +*** 4245,4250 **** +--- 4245,4259 ---- + {"windows", (PyObject *)(void *)&TheWindowList}, + {"tabpages", (PyObject *)(void *)&TheTabPageList}, + {"current", (PyObject *)(void *)&TheCurrent}, ++ ++ {"Buffer", (PyObject *)&BufferType}, ++ {"Range", (PyObject *)&RangeType}, ++ {"Window", (PyObject *)&WindowType}, ++ {"TabPage", (PyObject *)&TabPageType}, ++ {"Dictionary", (PyObject *)&DictionaryType}, ++ {"List", (PyObject *)&ListType}, ++ {"Function", (PyObject *)&FunctionType}, ++ {"Options", (PyObject *)&OptionsType}, + }; + + typedef int (*object_adder)(PyObject *, const char *, PyObject *); +*** ../vim-7.3.995/src/testdir/test86.in 2013-05-17 13:37:57.000000000 +0200 +--- src/testdir/test86.in 2013-05-21 19:21:58.000000000 +0200 +*************** +*** 631,640 **** + cb.append('Current line: ' + repr(vim.current.line)) + for b in vim.buffers: + if b is not cb: +! vim.command('bwipeout! ' + b.number) + EOF + :tabonly! + :only! + :endfun + :" + :call Test() +--- 631,656 ---- + cb.append('Current line: ' + repr(vim.current.line)) + for b in vim.buffers: + if b is not cb: +! vim.command('bwipeout! ' + str(b.number)) + EOF + :tabonly! + :only! ++ :" ++ :" Test types ++ py << EOF ++ for expr, attr in ( ++ ('vim.vars', 'Dictionary'), ++ ('vim.options', 'Options'), ++ ('vim.bindeval("{}")', 'Dictionary'), ++ ('vim.bindeval("[]")', 'List'), ++ ('vim.bindeval("function(\'tr\')")', 'Function'), ++ ('vim.current.buffer', 'Buffer'), ++ ('vim.current.range', 'Range'), ++ ('vim.current.window', 'Window'), ++ ('vim.current.tabpage', 'TabPage'), ++ ): ++ cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr))) ++ EOF + :endfun + :" + :call Test() +*** ../vim-7.3.995/src/testdir/test86.ok 2013-05-17 16:18:27.000000000 +0200 +--- src/testdir/test86.ok 2013-05-21 19:21:58.000000000 +0200 +*************** +*** 333,339 **** + Current tab pages: + (1): 1 windows, current is + Windows: +! (1): displays buffer ; cursor is at (954, 0) + (2): 1 windows, current is + Windows: + (1): displays buffer ; cursor is at (1, 0) +--- 333,339 ---- + Current tab pages: + (1): 1 windows, current is + Windows: +! (1): displays buffer ; cursor is at (970, 0) + (2): 1 windows, current is + Windows: + (1): displays buffer ; cursor is at (1, 0) +*************** +*** 359,361 **** +--- 359,370 ---- + Current window: + Current buffer: + Current line: 'Type error at assigning None to vim.current.buffer' ++ vim.vars:Dictionary:True ++ vim.options:Options:True ++ vim.bindeval("{}"):Dictionary:True ++ vim.bindeval("[]"):List:True ++ vim.bindeval("function('tr')"):Function:True ++ vim.current.buffer:Buffer:True ++ vim.current.range:Range:True ++ vim.current.window:Window:True ++ vim.current.tabpage:TabPage:True +*** ../vim-7.3.995/src/testdir/test87.in 2013-05-17 13:37:57.000000000 +0200 +--- src/testdir/test87.in 2013-05-21 19:21:58.000000000 +0200 +*************** +*** 622,627 **** +--- 622,643 ---- + EOF + :tabonly! + :only! ++ :" ++ :" Test types ++ py3 << EOF ++ for expr, attr in ( ++ ('vim.vars', 'Dictionary'), ++ ('vim.options', 'Options'), ++ ('vim.bindeval("{}")', 'Dictionary'), ++ ('vim.bindeval("[]")', 'List'), ++ ('vim.bindeval("function(\'tr\')")', 'Function'), ++ ('vim.current.buffer', 'Buffer'), ++ ('vim.current.range', 'Range'), ++ ('vim.current.window', 'Window'), ++ ('vim.current.tabpage', 'TabPage'), ++ ): ++ cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr))) ++ EOF + :endfun + :" + :call Test() +*** ../vim-7.3.995/src/testdir/test87.ok 2013-05-21 18:19:33.000000000 +0200 +--- src/testdir/test87.ok 2013-05-21 19:21:58.000000000 +0200 +*************** +*** 322,328 **** + Current tab pages: + (1): 1 windows, current is + Windows: +! (1): displays buffer ; cursor is at (930, 0) + (2): 1 windows, current is + Windows: + (1): displays buffer ; cursor is at (1, 0) +--- 322,328 ---- + Current tab pages: + (1): 1 windows, current is + Windows: +! (1): displays buffer ; cursor is at (946, 0) + (2): 1 windows, current is + Windows: + (1): displays buffer ; cursor is at (1, 0) +*************** +*** 348,350 **** +--- 348,359 ---- + Current window: + Current buffer: + Current line: 'Type error at assigning None to vim.current.buffer' ++ vim.vars:Dictionary:True ++ vim.options:Options:True ++ vim.bindeval("{}"):Dictionary:True ++ vim.bindeval("[]"):List:True ++ vim.bindeval("function('tr')"):Function:True ++ vim.current.buffer:Buffer:True ++ vim.current.range:Range:True ++ vim.current.window:Window:True ++ vim.current.tabpage:TabPage:True +*** ../vim-7.3.995/src/version.c 2013-05-21 19:10:56.000000000 +0200 +--- src/version.c 2013-05-21 19:48:38.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 996, + /**/ + +-- +SUPERIMPOSE "England AD 787". After a few more seconds we hear hoofbeats in +the distance. They come slowly closer. Then out of the mist comes KING +ARTHUR followed by a SERVANT who is banging two half coconuts together. + "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/7.3.997 b/7.3.997 new file mode 100644 index 00000000..3839e54a --- /dev/null +++ b/7.3.997 @@ -0,0 +1,983 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.997 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.997 +Problem: Vim and Python exceptions are different. +Solution: Make Vim exceptions be Python exceptions. (ZyX) +Files: src/if_py_both.h, src/testdir/test86.in, src/testdir/test86.ok, + src/testdir/test87.in, src/testdir/test87.ok + + +*** ../vim-7.3.996/src/if_py_both.h 2013-05-21 19:49:58.000000000 +0200 +--- src/if_py_both.h 2013-05-21 20:35:07.000000000 +0200 +*************** +*** 272,291 **** + /* Check to see whether a Vim error has been reported, or a keyboard + * interrupt has been detected. + */ + static int +! VimErrorCheck(void) + { + if (got_int) + { + PyErr_SetNone(PyExc_KeyboardInterrupt); + return 1; + } +! else if (did_emsg && !PyErr_Occurred()) + { +! PyErr_SetNone(VimError); + return 1; + } + + return 0; + } + +--- 272,313 ---- + /* Check to see whether a Vim error has been reported, or a keyboard + * interrupt has been detected. + */ ++ ++ static void ++ VimTryStart(void) ++ { ++ ++trylevel; ++ } ++ + static int +! VimTryEnd(void) + { ++ --trylevel; + if (got_int) + { + PyErr_SetNone(PyExc_KeyboardInterrupt); + return 1; + } +! else if (!did_throw) +! return 0; +! else if (PyErr_Occurred()) +! return 1; +! else + { +! PyErr_SetVim((char *) current_exception->value); +! discard_current_exception(); + return 1; + } ++ } + ++ static int ++ VimCheckInterrupt(void) ++ { ++ if (got_int) ++ { ++ PyErr_SetNone(PyExc_KeyboardInterrupt); ++ return 1; ++ } + return 0; + } + +*************** +*** 306,322 **** + Py_BEGIN_ALLOW_THREADS + Python_Lock_Vim(); + + do_cmdline_cmd((char_u *)cmd); + update_screen(VALID); + + Python_Release_Vim(); + Py_END_ALLOW_THREADS + +! if (VimErrorCheck()) + result = NULL; + else + result = Py_None; + + Py_XINCREF(result); + return result; + } +--- 328,346 ---- + Py_BEGIN_ALLOW_THREADS + Python_Lock_Vim(); + ++ VimTryStart(); + do_cmdline_cmd((char_u *)cmd); + update_screen(VALID); + + Python_Release_Vim(); + Py_END_ALLOW_THREADS + +! if (VimTryEnd()) + result = NULL; + else + result = Py_None; + ++ + Py_XINCREF(result); + return result; + } +*************** +*** 449,459 **** + + Py_BEGIN_ALLOW_THREADS + Python_Lock_Vim(); + our_tv = eval_expr((char_u *)expr, NULL); +- + Python_Release_Vim(); + Py_END_ALLOW_THREADS + + if (our_tv == NULL) + { + PyErr_SetVim(_("invalid expression")); +--- 473,486 ---- + + Py_BEGIN_ALLOW_THREADS + Python_Lock_Vim(); ++ VimTryStart(); + our_tv = eval_expr((char_u *)expr, NULL); + Python_Release_Vim(); + Py_END_ALLOW_THREADS + ++ if (VimTryEnd()) ++ return NULL; ++ + if (our_tv == NULL) + { + PyErr_SetVim(_("invalid expression")); +*************** +*** 490,500 **** + + Py_BEGIN_ALLOW_THREADS + Python_Lock_Vim(); + our_tv = eval_expr((char_u *)expr, NULL); +- + Python_Release_Vim(); + Py_END_ALLOW_THREADS + + if (our_tv == NULL) + { + PyErr_SetVim(_("invalid expression")); +--- 517,530 ---- + + Py_BEGIN_ALLOW_THREADS + Python_Lock_Vim(); ++ VimTryStart(); + our_tv = eval_expr((char_u *)expr, NULL); + Python_Release_Vim(); + Py_END_ALLOW_THREADS + ++ if (VimTryEnd()) ++ return NULL; ++ + if (our_tv == NULL) + { + PyErr_SetVim(_("invalid expression")); +*************** +*** 1324,1335 **** + Py_BEGIN_ALLOW_THREADS + Python_Lock_Vim(); + + error = func_call(name, &args, selfdict, &rettv); + + Python_Release_Vim(); + Py_END_ALLOW_THREADS + +! if (error != OK) + { + result = NULL; + PyErr_SetVim(_("failed to run function")); +--- 1354,1368 ---- + Py_BEGIN_ALLOW_THREADS + Python_Lock_Vim(); + ++ VimTryStart(); + error = func_call(name, &args, selfdict, &rettv); + + Python_Release_Vim(); + Py_END_ALLOW_THREADS + +! if (VimTryEnd()) +! result = NULL; +! else if (error != OK) + { + result = NULL; + PyErr_SetVim(_("failed to run function")); +*************** +*** 1486,1499 **** + win_T *save_curwin; + tabpage_T *save_curtab; + buf_T *save_curbuf; +- int r = 0; + + switch (opt_type) + { + case SREQ_WIN: + if (switch_win(&save_curwin, &save_curtab, (win_T *)from, + win_find_tabpage((win_T *)from)) == FAIL) + { + PyErr_SetVim("Problem while switching windows."); + return -1; + } +--- 1519,1534 ---- + win_T *save_curwin; + tabpage_T *save_curtab; + buf_T *save_curbuf; + ++ VimTryStart(); + switch (opt_type) + { + case SREQ_WIN: + if (switch_win(&save_curwin, &save_curtab, (win_T *)from, + win_find_tabpage((win_T *)from)) == FAIL) + { ++ if (VimTryEnd()) ++ return -1; + PyErr_SetVim("Problem while switching windows."); + return -1; + } +*************** +*** 1509,1515 **** + set_option_value(key, numval, stringval, opt_flags); + break; + } +! return r; + } + + static int +--- 1544,1550 ---- + set_option_value(key, numval, stringval, opt_flags); + break; + } +! return VimTryEnd(); + } + + static int +*************** +*** 1961,1967 **** + } + + /* Check for keyboard interrupts */ +! if (VimErrorCheck()) + return -1; + + self->win->w_cursor.lnum = lnum; +--- 1996,2002 ---- + } + + /* Check for keyboard interrupts */ +! if (VimCheckInterrupt()) + return -1; + + self->win->w_cursor.lnum = lnum; +*************** +*** 1988,1998 **** + #endif + savewin = curwin; + curwin = self->win; + win_setheight(height); + curwin = savewin; +! +! /* Check for keyboard interrupts */ +! if (VimErrorCheck()) + return -1; + + return 0; +--- 2023,2033 ---- + #endif + savewin = curwin; + curwin = self->win; ++ ++ VimTryStart(); + win_setheight(height); + curwin = savewin; +! if (VimTryEnd()) + return -1; + + return 0; +*************** +*** 2011,2021 **** + #endif + savewin = curwin; + curwin = self->win; + win_setwidth(width); + curwin = savewin; +! +! /* Check for keyboard interrupts */ +! if (VimErrorCheck()) + return -1; + + return 0; +--- 2046,2056 ---- + #endif + savewin = curwin; + curwin = self->win; ++ ++ VimTryStart(); + win_setwidth(width); + curwin = savewin; +! if (VimTryEnd()) + return -1; + + return 0; +*************** +*** 2304,2309 **** +--- 2339,2346 ---- + PyErr_Clear(); + switch_buffer(&savebuf, buf); + ++ VimTryStart(); ++ + if (u_savedel((linenr_T)n, 1L) == FAIL) + PyErr_SetVim(_("cannot save undo information")); + else if (ml_delete((linenr_T)n, FALSE) == FAIL) +*************** +*** 2317,2323 **** + + restore_buffer(savebuf); + +! if (PyErr_Occurred() || VimErrorCheck()) + return FAIL; + + if (len_change) +--- 2354,2360 ---- + + restore_buffer(savebuf); + +! if (VimTryEnd()) + return FAIL; + + if (len_change) +*************** +*** 2333,2338 **** +--- 2370,2377 ---- + if (save == NULL) + return FAIL; + ++ VimTryStart(); ++ + /* We do not need to free "save" if ml_replace() consumes it. */ + PyErr_Clear(); + switch_buffer(&savebuf, buf); +*************** +*** 2356,2362 **** + if (buf == savebuf) + check_cursor_col(); + +! if (PyErr_Occurred() || VimErrorCheck()) + return FAIL; + + if (len_change) +--- 2395,2401 ---- + if (buf == savebuf) + check_cursor_col(); + +! if (VimTryEnd()) + return FAIL; + + if (len_change) +*************** +*** 2395,2400 **** +--- 2434,2440 ---- + buf_T *savebuf; + + PyErr_Clear(); ++ VimTryStart(); + switch_buffer(&savebuf, buf); + + if (u_savedel((linenr_T)lo, (long)n) == FAIL) +*************** +*** 2416,2422 **** + + restore_buffer(savebuf); + +! if (PyErr_Occurred() || VimErrorCheck()) + return FAIL; + + if (len_change) +--- 2456,2462 ---- + + restore_buffer(savebuf); + +! if (VimTryEnd()) + return FAIL; + + if (len_change) +*************** +*** 2459,2464 **** +--- 2499,2505 ---- + } + } + ++ VimTryStart(); + PyErr_Clear(); + + // START of region without "return". Must call restore_buffer()! +*************** +*** 2545,2551 **** + // END of region without "return". + restore_buffer(savebuf); + +! if (PyErr_Occurred() || VimErrorCheck()) + return FAIL; + + if (len_change) +--- 2586,2592 ---- + // END of region without "return". + restore_buffer(savebuf); + +! if (VimTryEnd()) + return FAIL; + + if (len_change) +*************** +*** 2583,2588 **** +--- 2624,2630 ---- + return FAIL; + + PyErr_Clear(); ++ VimTryStart(); + switch_buffer(&savebuf, buf); + + if (u_save((linenr_T)n, (linenr_T)(n+1)) == FAIL) +*************** +*** 2596,2602 **** + restore_buffer(savebuf); + update_screen(VALID); + +! if (PyErr_Occurred() || VimErrorCheck()) + return FAIL; + + if (len_change) +--- 2638,2644 ---- + restore_buffer(savebuf); + update_screen(VALID); + +! if (VimTryEnd()) + return FAIL; + + if (len_change) +*************** +*** 2633,2638 **** +--- 2675,2681 ---- + } + + PyErr_Clear(); ++ VimTryStart(); + switch_buffer(&savebuf, buf); + + if (u_save((linenr_T)n, (linenr_T)(n + 1)) == FAIL) +*************** +*** 2666,2672 **** + restore_buffer(savebuf); + update_screen(VALID); + +! if (PyErr_Occurred() || VimErrorCheck()) + return FAIL; + + if (len_change) +--- 2709,2715 ---- + restore_buffer(savebuf); + update_screen(VALID); + +! if (VimTryEnd()) + return FAIL; + + if (len_change) +*************** +*** 2896,2902 **** + static void + RangeDestructor(RangeObject *self) + { +! Py_DECREF(self->buf); + DESTRUCTOR_FINISH(self); + } + +--- 2939,2945 ---- + static void + RangeDestructor(RangeObject *self) + { +! Py_XDECREF(self->buf); + DESTRUCTOR_FINISH(self); + } + +*************** +*** 3078,3086 **** +--- 3121,3132 ---- + return NULL; + mark = *pmark; + ++ VimTryStart(); + switch_buffer(&savebuf, self->buf); + posp = getmark(mark, FALSE); + restore_buffer(savebuf); ++ if (VimTryEnd()) ++ return NULL; + + if (posp == NULL) + { +*************** +*** 3088,3097 **** + return NULL; + } + +- /* Check for keyboard interrupt */ +- if (VimErrorCheck()) +- return NULL; +- + if (posp->lnum <= 0) + { + /* Or raise an error? */ +--- 3134,3139 ---- +*************** +*** 3330,3342 **** + return -1; + count = ((BufferObject *)(value))->buf->b_fnum; + + if (do_buffer(DOBUF_GOTO, DOBUF_FIRST, FORWARD, count, 0) == FAIL) + { + PyErr_SetVim(_("failed to switch to given buffer")); + return -1; + } + +! return 0; + } + else if (strcmp(name, "window") == 0) + { +--- 3372,3387 ---- + return -1; + count = ((BufferObject *)(value))->buf->b_fnum; + ++ VimTryStart(); + if (do_buffer(DOBUF_GOTO, DOBUF_FIRST, FORWARD, count, 0) == FAIL) + { ++ if (VimTryEnd()) ++ return -1; + PyErr_SetVim(_("failed to switch to given buffer")); + return -1; + } + +! return VimTryEnd(); + } + else if (strcmp(name, "window") == 0) + { +*************** +*** 3359,3373 **** + return -1; + } + + win_goto(((WindowObject *)(value))->win); + if (((WindowObject *)(value))->win != curwin) + { + PyErr_SetString(PyExc_RuntimeError, + _("did not switch to the specified window")); + return -1; + } + +! return 0; + } + else if (strcmp(name, "tabpage") == 0) + { +--- 3404,3421 ---- + return -1; + } + ++ VimTryStart(); + win_goto(((WindowObject *)(value))->win); + if (((WindowObject *)(value))->win != curwin) + { ++ if (VimTryEnd()) ++ return -1; + PyErr_SetString(PyExc_RuntimeError, + _("did not switch to the specified window")); + return -1; + } + +! return VimTryEnd(); + } + else if (strcmp(name, "tabpage") == 0) + { +*************** +*** 3380,3394 **** + if (CheckTabPage((TabPageObject *)(value))) + return -1; + + goto_tabpage_tp(((TabPageObject *)(value))->tab, TRUE, TRUE); + if (((TabPageObject *)(value))->tab != curtab) + { + PyErr_SetString(PyExc_RuntimeError, + _("did not switch to the specified tab page")); + return -1; + } + +! return 0; + } + else + { +--- 3428,3445 ---- + if (CheckTabPage((TabPageObject *)(value))) + return -1; + ++ VimTryStart(); + goto_tabpage_tp(((TabPageObject *)(value))->tab, TRUE, TRUE); + if (((TabPageObject *)(value))->tab != curtab) + { ++ if (VimTryEnd()) ++ return -1; + PyErr_SetString(PyExc_RuntimeError, + _("did not switch to the specified tab page")); + return -1; + } + +! return VimTryEnd(); + } + else + { +*** ../vim-7.3.996/src/testdir/test86.in 2013-05-21 19:49:58.000000000 +0200 +--- src/testdir/test86.in 2013-05-21 20:34:32.000000000 +0200 +*************** +*** 380,399 **** + try: + exec(s, g, l) + except: +! vim.command('throw ' + repr(sys.exc_type.__name__)) + + def ev(s, g=globals(), l=locals()): + try: + return eval(s, g, l) + except: +! vim.command('throw ' + repr(sys.exc_type.__name__)) + return 0 + EOF + :function E(s) + : python e(vim.eval('a:s')) + :endfunction + :function Ev(s) +! : return pyeval('ev(vim.eval("a:s"))') + :endfunction + :py gopts1=vim.options + :py wopts1=vim.windows[2].options +--- 380,403 ---- + try: + exec(s, g, l) + except: +! vim.command('return ' + repr(sys.exc_type.__name__)) + + def ev(s, g=globals(), l=locals()): + try: + return eval(s, g, l) + except: +! vim.command('let exc=' + repr(sys.exc_type.__name__)) + return 0 + EOF + :function E(s) + : python e(vim.eval('a:s')) + :endfunction + :function Ev(s) +! : let r=pyeval('ev(vim.eval("a:s"))') +! : if exists('exc') +! : throw exc +! : endif +! : return r + :endfunction + :py gopts1=vim.options + :py wopts1=vim.windows[2].options +*************** +*** 437,463 **** + : catch + : put =' p/'.v.'! '.v:exception + : endtry +! : try +! : call E(v.'["'.oname.'"]=invval') +! : catch +! : put =' inv: '.string(invval).'! '.v:exception +! : endtry + : for vv in (v is# 'gopts1' ? [v] : [v, v[:-2].'2', v[:-2].'3']) + : let val=substitute(vv, '^.opts', 'oval', '') +! : try +! : call E(vv.'["'.oname.'"]='.val) +! : catch +! : put =' '.vv.'! '.v:exception +! : endtry + : endfor + : endfor + : call RecVars(oname) + : for v in ['wopts3', 'bopts3'] +! : try +! : call E('del '.v.'["'.oname.'"]') +! : catch +! : put =' del '.v.'! '.v:exception +! : endtry + : endfor + : call RecVars(oname) + :endfor +--- 441,464 ---- + : catch + : put =' p/'.v.'! '.v:exception + : endtry +! : let r=E(v.'['''.oname.''']=invval') +! : if r isnot 0 +! : put =' inv: '.string(invval).'! '.r +! : endif + : for vv in (v is# 'gopts1' ? [v] : [v, v[:-2].'2', v[:-2].'3']) + : let val=substitute(vv, '^.opts', 'oval', '') +! : let r=E(vv.'['''.oname.''']='.val) +! : if r isnot 0 +! : put =' '.vv.'! '.r +! : endif + : endfor + : endfor + : call RecVars(oname) + : for v in ['wopts3', 'bopts3'] +! : let r=E('del '.v.'["'.oname.'"]') +! : if r isnot 0 +! : put =' del '.v.'! '.r +! : endif + : endfor + : call RecVars(oname) + :endfor +*************** +*** 651,656 **** +--- 652,676 ---- + ): + cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr))) + EOF ++ :" ++ :" Test exceptions ++ :fun Exe(e) ++ : execute a:e ++ :endfun ++ py << EOF ++ def ee(expr, g=globals(), l=locals()): ++ try: ++ exec(expr, g, l) ++ except: ++ cb.append(repr(sys.exc_info()[:2])) ++ Exe = vim.bindeval('function("Exe")') ++ ee('vim.command("throw \'abc\'")') ++ ee('Exe("throw \'def\'")') ++ ee('vim.eval("Exe(\'throw \'\'ghi\'\'\')")') ++ ee('vim.eval("Exe(\'echoerr \'\'jkl\'\'\')")') ++ ee('vim.eval("Exe(\'xxx_non_existent_command_xxx\')")') ++ ee('vim.bindeval("Exe(\'xxx_non_existent_command_xxx\')")') ++ EOF + :endfun + :" + :call Test() +*** ../vim-7.3.996/src/testdir/test86.ok 2013-05-21 19:49:58.000000000 +0200 +--- src/testdir/test86.ok 2013-05-21 20:38:29.000000000 +0200 +*************** +*** 333,339 **** + Current tab pages: + (1): 1 windows, current is + Windows: +! (1): displays buffer ; cursor is at (970, 0) + (2): 1 windows, current is + Windows: + (1): displays buffer ; cursor is at (1, 0) +--- 333,339 ---- + Current tab pages: + (1): 1 windows, current is + Windows: +! (1): displays buffer ; cursor is at (990, 0) + (2): 1 windows, current is + Windows: + (1): displays buffer ; cursor is at (1, 0) +*************** +*** 368,370 **** +--- 368,376 ---- + vim.current.range:Range:True + vim.current.window:Window:True + vim.current.tabpage:TabPage:True ++ (, error('abc',)) ++ (, error('def',)) ++ (, error('ghi',)) ++ (, error('Vim(echoerr):jkl',)) ++ (, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)) ++ (, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)) +*** ../vim-7.3.996/src/testdir/test87.in 2013-05-21 19:49:58.000000000 +0200 +--- src/testdir/test87.in 2013-05-21 20:34:32.000000000 +0200 +*************** +*** 367,386 **** + try: + exec(s, g, l) + except Exception as e: +! vim.command('throw ' + repr(e.__class__.__name__)) + + def ev(s, g=globals(), l=locals()): + try: + return eval(s, g, l) + except Exception as e: +! vim.command('throw ' + repr(e.__class__.__name__)) + return 0 + EOF + :function E(s) + : python3 e(vim.eval('a:s')) + :endfunction + :function Ev(s) +! : return py3eval('ev(vim.eval("a:s"))') + :endfunction + :py3 gopts1=vim.options + :py3 wopts1=vim.windows[2].options +--- 367,390 ---- + try: + exec(s, g, l) + except Exception as e: +! vim.command('return ' + repr(e.__class__.__name__)) + + def ev(s, g=globals(), l=locals()): + try: + return eval(s, g, l) + except Exception as e: +! vim.command('let exc=' + repr(e.__class__.__name__)) + return 0 + EOF + :function E(s) + : python3 e(vim.eval('a:s')) + :endfunction + :function Ev(s) +! : let r=py3eval('ev(vim.eval("a:s"))') +! : if exists('exc') +! : throw exc +! : endif +! : return r + :endfunction + :py3 gopts1=vim.options + :py3 wopts1=vim.windows[2].options +*************** +*** 424,450 **** + : catch + : put =' p/'.v.'! '.v:exception + : endtry +! : try +! : call E(v.'["'.oname.'"]=invval') +! : catch +! : put =' inv: '.string(invval).'! '.v:exception +! : endtry + : for vv in (v is# 'gopts1' ? [v] : [v, v[:-2].'2', v[:-2].'3']) + : let val=substitute(vv, '^.opts', 'oval', '') +! : try +! : call E(vv.'["'.oname.'"]='.val) +! : catch +! : put =' '.vv.'! '.v:exception +! : endtry + : endfor + : endfor + : call RecVars(oname) + : for v in ['wopts3', 'bopts3'] +! : try +! : call E('del '.v.'["'.oname.'"]') +! : catch +! : put =' del '.v.'! '.v:exception +! : endtry + : endfor + : call RecVars(oname) + :endfor +--- 428,451 ---- + : catch + : put =' p/'.v.'! '.v:exception + : endtry +! : let r=E(v.'['''.oname.''']=invval') +! : if r isnot 0 +! : put =' inv: '.string(invval).'! '.r +! : endif + : for vv in (v is# 'gopts1' ? [v] : [v, v[:-2].'2', v[:-2].'3']) + : let val=substitute(vv, '^.opts', 'oval', '') +! : let r=E(vv.'['''.oname.''']='.val) +! : if r isnot 0 +! : put =' '.vv.'! '.r +! : endif + : endfor + : endfor + : call RecVars(oname) + : for v in ['wopts3', 'bopts3'] +! : let r=E('del '.v.'["'.oname.'"]') +! : if r isnot 0 +! : put =' del '.v.'! '.r +! : endif + : endfor + : call RecVars(oname) + :endfor +*************** +*** 638,643 **** +--- 639,663 ---- + ): + cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr))) + EOF ++ :" ++ :" Test exceptions ++ :fun Exe(e) ++ : execute a:e ++ :endfun ++ py3 << EOF ++ def ee(expr, g=globals(), l=locals()): ++ try: ++ exec(expr, g, l) ++ except Exception as e: ++ cb.append(repr((e.__class__, e))) ++ Exe = vim.bindeval('function("Exe")') ++ ee('vim.command("throw \'abc\'")') ++ ee('Exe("throw \'def\'")') ++ ee('vim.eval("Exe(\'throw \'\'ghi\'\'\')")') ++ ee('vim.eval("Exe(\'echoerr \'\'jkl\'\'\')")') ++ ee('vim.eval("Exe(\'xxx_non_existent_command_xxx\')")') ++ ee('vim.bindeval("Exe(\'xxx_non_existent_command_xxx\')")') ++ EOF + :endfun + :" + :call Test() +*** ../vim-7.3.996/src/testdir/test87.ok 2013-05-21 19:49:58.000000000 +0200 +--- src/testdir/test87.ok 2013-05-21 20:38:46.000000000 +0200 +*************** +*** 322,328 **** + Current tab pages: + (1): 1 windows, current is + Windows: +! (1): displays buffer ; cursor is at (946, 0) + (2): 1 windows, current is + Windows: + (1): displays buffer ; cursor is at (1, 0) +--- 322,328 ---- + Current tab pages: + (1): 1 windows, current is + Windows: +! (1): displays buffer ; cursor is at (966, 0) + (2): 1 windows, current is + Windows: + (1): displays buffer ; cursor is at (1, 0) +*************** +*** 357,359 **** +--- 357,365 ---- + vim.current.range:Range:True + vim.current.window:Window:True + vim.current.tabpage:TabPage:True ++ (, error('abc',)) ++ (, error('def',)) ++ (, error('ghi',)) ++ (, error('Vim(echoerr):jkl',)) ++ (, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)) ++ (, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)) +*** ../vim-7.3.996/src/version.c 2013-05-21 19:49:58.000000000 +0200 +--- src/version.c 2013-05-21 20:32:46.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 997, + /**/ + +-- +ARTHUR: It is I, Arthur, son of Uther Pendragon, from the castle of Camelot. + King of all Britons, defeator of the Saxons, sovereign of all England! + [Pause] +SOLDIER: Get away! + "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/7.3.998 b/7.3.998 new file mode 100644 index 00000000..952cb300 --- /dev/null +++ b/7.3.998 @@ -0,0 +1,414 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.998 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.998 +Problem: Python: garbage collection issues. +Solution: Fix the GC issues: Use proper DESTRUCTOR_FINISH: avoids negative + refcounts, use PyObject_GC_* for objects with tp_traverse and + tp_clear, add RangeTraverse and RangeClear, use Py_XDECREF in some + places. (ZyX) +Files: src/if_py_both.h, src/if_python3.c, src/if_python.c + + +*** ../vim-7.3.997/src/if_py_both.h 2013-05-21 20:40:35.000000000 +0200 +--- src/if_py_both.h 2013-05-21 20:44:44.000000000 +0200 +*************** +*** 461,467 **** + } + + static PyObject * +! VimEval(PyObject *self UNUSED, PyObject *args UNUSED) + { + char *expr; + typval_T *our_tv; +--- 461,467 ---- + } + + static PyObject * +! VimEval(PyObject *self UNUSED, PyObject *args) + { + char *expr; + typval_T *our_tv; +*************** +*** 602,608 **** + { + IterObject *self; + +! self = PyObject_NEW(IterObject, &IterType); + self->cur = start; + self->next = next; + self->destruct = destruct; +--- 602,608 ---- + { + IterObject *self; + +! self = PyObject_GC_New(IterObject, &IterType); + self->cur = start; + self->next = next; + self->destruct = destruct; +*************** +*** 615,623 **** + static void + IterDestructor(IterObject *self) + { + self->destruct(self->cur); +! +! DESTRUCTOR_FINISH(self); + } + + static int +--- 615,623 ---- + static void + IterDestructor(IterObject *self) + { ++ PyObject_GC_UnTrack((void *)(self)); + self->destruct(self->cur); +! PyObject_GC_Del((void *)(self)); + } + + static int +*************** +*** 1414,1420 **** + { + OptionsObject *self; + +! self = PyObject_NEW(OptionsObject, &OptionsType); + if (self == NULL) + return NULL; + +--- 1414,1420 ---- + { + OptionsObject *self; + +! self = PyObject_GC_New(OptionsObject, &OptionsType); + if (self == NULL) + return NULL; + +*************** +*** 1431,1439 **** + static void + OptionsDestructor(OptionsObject *self) + { +! if (self->fromObj) +! Py_DECREF(self->fromObj); +! DESTRUCTOR_FINISH(self); + } + + static int +--- 1431,1439 ---- + static void + OptionsDestructor(OptionsObject *self) + { +! PyObject_GC_UnTrack((void *)(self)); +! Py_XDECREF(self->fromObj); +! PyObject_GC_Del((void *)(self)); + } + + static int +*************** +*** 1869,1875 **** + } + else + { +! self = PyObject_NEW(WindowObject, &WindowType); + if (self == NULL) + return NULL; + self->win = win; +--- 1869,1875 ---- + } + else + { +! self = PyObject_GC_New(WindowObject, &WindowType); + if (self == NULL) + return NULL; + self->win = win; +*************** +*** 1884,1895 **** + static void + WindowDestructor(WindowObject *self) + { + if (self->win && self->win != INVALID_WINDOW_VALUE) + WIN_PYTHON_REF(self->win) = NULL; + +! Py_DECREF(((PyObject *)(self->tabObject))); + +! DESTRUCTOR_FINISH(self); + } + + static win_T * +--- 1884,1908 ---- + static void + WindowDestructor(WindowObject *self) + { ++ PyObject_GC_UnTrack((void *)(self)); + if (self->win && self->win != INVALID_WINDOW_VALUE) + WIN_PYTHON_REF(self->win) = NULL; ++ Py_XDECREF(((PyObject *)(self->tabObject))); ++ PyObject_GC_Del((void *)(self)); ++ } + +! static int +! WindowTraverse(WindowObject *self, visitproc visit, void *arg) +! { +! Py_VISIT(((PyObject *)(self->tabObject))); +! return 0; +! } + +! static int +! WindowClear(WindowObject *self) +! { +! Py_CLEAR(self->tabObject); +! return 0; + } + + static win_T * +*************** +*** 1909,1927 **** + else + return firstwin; + } +- static int +- WindowTraverse(WindowObject *self, visitproc visit, void *arg) +- { +- Py_VISIT(((PyObject *)(self->tabObject))); +- return 0; +- } +- +- static int +- WindowClear(WindowObject *self) +- { +- Py_CLEAR(self->tabObject); +- return 0; +- } + + static PyObject * + WindowAttr(WindowObject *self, char *name) +--- 1922,1927 ---- +*************** +*** 2917,2923 **** + { + BufferObject *bufr; + RangeObject *self; +! self = PyObject_NEW(RangeObject, &RangeType); + if (self == NULL) + return NULL; + +--- 2917,2923 ---- + { + BufferObject *bufr; + RangeObject *self; +! self = PyObject_GC_New(RangeObject, &RangeType); + if (self == NULL) + return NULL; + +*************** +*** 2939,2946 **** + static void + RangeDestructor(RangeObject *self) + { + Py_XDECREF(self->buf); +! DESTRUCTOR_FINISH(self); + } + + static PyInt +--- 2939,2961 ---- + static void + RangeDestructor(RangeObject *self) + { ++ PyObject_GC_UnTrack((void *)(self)); + Py_XDECREF(self->buf); +! PyObject_GC_Del((void *)(self)); +! } +! +! static int +! RangeTraverse(RangeObject *self, visitproc visit, void *arg) +! { +! Py_VISIT(((PyObject *)(self->buf))); +! return 0; +! } +! +! static int +! RangeClear(RangeObject *self) +! { +! Py_CLEAR(self->buf); +! return 0; + } + + static PyInt +*************** +*** 3267,3280 **** + static int + BufMapIterTraverse(PyObject *buffer, visitproc visit, void *arg) + { +! Py_VISIT(buffer); + return 0; + } + + static int + BufMapIterClear(PyObject **buffer) + { +! Py_CLEAR(*buffer); + return 0; + } + +--- 3282,3297 ---- + static int + BufMapIterTraverse(PyObject *buffer, visitproc visit, void *arg) + { +! if (buffer) +! Py_VISIT(buffer); + return 0; + } + + static int + BufMapIterClear(PyObject **buffer) + { +! if (*buffer) +! Py_CLEAR(*buffer); + return 0; + } + +*************** +*** 4144,4149 **** +--- 4161,4168 ---- + RangeType.tp_flags = Py_TPFLAGS_DEFAULT; + RangeType.tp_doc = "vim Range object"; + RangeType.tp_methods = RangeMethods; ++ RangeType.tp_traverse = (traverseproc)RangeTraverse; ++ RangeType.tp_clear = (inquiry)RangeClear; + #if PY_MAJOR_VERSION >= 3 + RangeType.tp_getattro = (getattrofunc)RangeGetattro; + RangeType.tp_alloc = call_PyType_GenericAlloc; +*** ../vim-7.3.997/src/if_python3.c 2013-05-21 19:10:56.000000000 +0200 +--- src/if_python3.c 2013-05-21 20:44:44.000000000 +0200 +*************** +*** 213,218 **** +--- 213,221 ---- + # define PyObject_Malloc py3_PyObject_Malloc + # define PyObject_Free py3_PyObject_Free + # endif ++ # define _PyObject_GC_New py3__PyObject_GC_New ++ # define PyObject_GC_Del py3_PyObject_GC_Del ++ # define PyObject_GC_UnTrack py3_PyObject_GC_UnTrack + # define PyType_GenericAlloc py3_PyType_GenericAlloc + # define PyType_GenericNew py3_PyType_GenericNew + # define PyModule_Create2 py3_PyModule_Create2 +*************** +*** 334,339 **** +--- 337,345 ---- + static void (*py3_PyObject_Free)(void*); + static void* (*py3_PyObject_Malloc)(size_t); + # endif ++ static PyObject*(*py3__PyObject_GC_New)(PyTypeObject *); ++ static void(*py3_PyObject_GC_Del)(void *); ++ static void(*py3_PyObject_GC_UnTrack)(void *); + static int (*py3_PyType_IsSubtype)(PyTypeObject *, PyTypeObject *); + + static HINSTANCE hinstPy3 = 0; /* Instance of python.dll */ +*************** +*** 463,468 **** +--- 469,477 ---- + {"PyObject_Malloc", (PYTHON_PROC*)&py3_PyObject_Malloc}, + {"PyObject_Free", (PYTHON_PROC*)&py3_PyObject_Free}, + # endif ++ {"_PyObject_GC_New", (PYTHON_PROC*)&py3__PyObject_GC_New}, ++ {"PyObject_GC_Del", (PYTHON_PROC*)&py3_PyObject_GC_Del}, ++ {"PyObject_GC_UnTrack", (PYTHON_PROC*)&py3_PyObject_GC_UnTrack}, + {"PyType_IsSubtype", (PYTHON_PROC*)&py3_PyType_IsSubtype}, + {"PyCapsule_New", (PYTHON_PROC*)&py3_PyCapsule_New}, + {"PyCapsule_GetPointer", (PYTHON_PROC*)&py3_PyCapsule_GetPointer}, +*************** +*** 638,644 **** + if (bytes != NULL) \ + Py_XDECREF(bytes); + +! #define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self); + + #define WIN_PYTHON_REF(win) win->w_python3_ref + #define BUF_PYTHON_REF(buf) buf->b_python3_ref +--- 647,653 ---- + if (bytes != NULL) \ + Py_XDECREF(bytes); + +! #define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self) + + #define WIN_PYTHON_REF(win) win->w_python3_ref + #define BUF_PYTHON_REF(buf) buf->b_python3_ref +*** ../vim-7.3.997/src/if_python.c 2013-05-21 19:10:56.000000000 +0200 +--- src/if_python.c 2013-05-21 20:44:44.000000000 +0200 +*************** +*** 224,229 **** +--- 224,232 ---- + # define Py_Finalize dll_Py_Finalize + # define Py_IsInitialized dll_Py_IsInitialized + # define _PyObject_New dll__PyObject_New ++ # define _PyObject_GC_New dll__PyObject_GC_New ++ # define PyObject_GC_Del dll_PyObject_GC_Del ++ # define PyObject_GC_UnTrack dll_PyObject_GC_UnTrack + # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000 + # define _PyObject_NextNotImplemented (*dll__PyObject_NextNotImplemented) + # endif +*************** +*** 331,336 **** +--- 334,342 ---- + static void(*dll_Py_Finalize)(void); + static int(*dll_Py_IsInitialized)(void); + static PyObject*(*dll__PyObject_New)(PyTypeObject *, PyObject *); ++ static PyObject*(*dll__PyObject_GC_New)(PyTypeObject *); ++ static void(*dll_PyObject_GC_Del)(void *); ++ static void(*dll_PyObject_GC_UnTrack)(void *); + static PyObject*(*dll__PyObject_Init)(PyObject *, PyTypeObject *); + static PyObject* (*dll_PyObject_GetIter)(PyObject *); + static int (*dll_PyObject_IsTrue)(PyObject *); +*************** +*** 474,479 **** +--- 480,488 ---- + {"Py_Finalize", (PYTHON_PROC*)&dll_Py_Finalize}, + {"Py_IsInitialized", (PYTHON_PROC*)&dll_Py_IsInitialized}, + {"_PyObject_New", (PYTHON_PROC*)&dll__PyObject_New}, ++ {"_PyObject_GC_New", (PYTHON_PROC*)&dll__PyObject_GC_New}, ++ {"PyObject_GC_Del", (PYTHON_PROC*)&dll_PyObject_GC_Del}, ++ {"PyObject_GC_UnTrack", (PYTHON_PROC*)&dll_PyObject_GC_UnTrack}, + {"PyObject_Init", (PYTHON_PROC*)&dll__PyObject_Init}, + {"PyObject_GetIter", (PYTHON_PROC*)&dll_PyObject_GetIter}, + {"PyObject_IsTrue", (PYTHON_PROC*)&dll_PyObject_IsTrue}, +*************** +*** 632,638 **** + #define DICTKEY_UNREF + #define DICTKEY_DECL + +! #define DESTRUCTOR_FINISH(self) Py_DECREF(self); + + #define WIN_PYTHON_REF(win) win->w_python_ref + #define BUF_PYTHON_REF(buf) buf->b_python_ref +--- 641,647 ---- + #define DICTKEY_UNREF + #define DICTKEY_DECL + +! #define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self); + + #define WIN_PYTHON_REF(win) win->w_python_ref + #define BUF_PYTHON_REF(buf) buf->b_python_ref +*** ../vim-7.3.997/src/version.c 2013-05-21 20:40:35.000000000 +0200 +--- src/version.c 2013-05-21 20:43:56.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 998, + /**/ + +-- +The problem with political jokes is that they get elected. + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/7.3.999 b/7.3.999 new file mode 100644 index 00000000..13bffc65 --- /dev/null +++ b/7.3.999 @@ -0,0 +1,165 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.999 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.999 +Problem: New regexp engine sets curbuf temporarily. +Solution: Use reg_buf instead, like the old engine. +Files: src/regexp_nfa.c + + +*** ../vim-7.3.998/src/regexp_nfa.c 2013-05-21 16:28:05.000000000 +0200 +--- src/regexp_nfa.c 2013-05-21 21:15:41.000000000 +0200 +*************** +*** 3125,3139 **** + int this_class; + + /* Get class of current and previous char (if it exists). */ +! this_class = mb_get_class(reginput); + if (this_class <= 1) + bow = FALSE; + else if (reg_prev_class() == this_class) + bow = FALSE; + } + #endif +! else if (!vim_iswordc(c) +! || (reginput > regline && vim_iswordc(reginput[-1]))) + bow = FALSE; + if (bow) + addstate(thislist, t->state->out, &t->sub, 0, listid, +--- 3125,3140 ---- + int this_class; + + /* Get class of current and previous char (if it exists). */ +! this_class = mb_get_class_buf(reginput, reg_buf); + if (this_class <= 1) + bow = FALSE; + else if (reg_prev_class() == this_class) + bow = FALSE; + } + #endif +! else if (!vim_iswordc_buf(c, reg_buf) +! || (reginput > regline +! && vim_iswordc_buf(reginput[-1], reg_buf))) + bow = FALSE; + if (bow) + addstate(thislist, t->state->out, &t->sub, 0, listid, +*************** +*** 3153,3167 **** + int this_class, prev_class; + + /* Get class of current and previous char (if it exists). */ +! this_class = mb_get_class(reginput); + prev_class = reg_prev_class(); + if (this_class == prev_class + || prev_class == 0 || prev_class == 1) + eow = FALSE; + } + #endif +! else if (!vim_iswordc(reginput[-1]) +! || (reginput[0] != NUL && vim_iswordc(c))) + eow = FALSE; + if (eow) + addstate(thislist, t->state->out, &t->sub, 0, listid, +--- 3154,3168 ---- + int this_class, prev_class; + + /* Get class of current and previous char (if it exists). */ +! this_class = mb_get_class_buf(reginput, reg_buf); + prev_class = reg_prev_class(); + if (this_class == prev_class + || prev_class == 0 || prev_class == 1) + eow = FALSE; + } + #endif +! else if (!vim_iswordc_buf(reginput[-1], reg_buf) +! || (reginput[0] != NUL && vim_iswordc_buf(c, reg_buf))) + eow = FALSE; + if (eow) + addstate(thislist, t->state->out, &t->sub, 0, listid, +*************** +*** 3267,3278 **** + break; + + case NFA_KWORD: /* \k */ +! result = vim_iswordp(reginput); + ADD_POS_NEG_STATE(t->state); + break; + + case NFA_SKWORD: /* \K */ +! result = !VIM_ISDIGIT(c) && vim_iswordp(reginput); + ADD_POS_NEG_STATE(t->state); + break; + +--- 3268,3279 ---- + break; + + case NFA_KWORD: /* \k */ +! result = vim_iswordp_buf(reginput, reg_buf); + ADD_POS_NEG_STATE(t->state); + break; + + case NFA_SKWORD: /* \K */ +! result = !VIM_ISDIGIT(c) && vim_iswordp_buf(reginput, reg_buf); + ADD_POS_NEG_STATE(t->state); + break; + +*************** +*** 3826,3834 **** + colnr_T col; /* column to start looking for match */ + proftime_T *tm UNUSED; /* timeout limit or NULL */ + { +- long r; +- buf_T *save_curbuf = curbuf; +- + reg_match = NULL; + reg_mmatch = rmp; + reg_buf = buf; +--- 3827,3832 ---- +*************** +*** 3842,3853 **** + #endif + ireg_maxcol = rmp->rmm_maxcol; + +! /* Need to switch to buffer "buf" to make vim_iswordc() work. */ +! curbuf = buf; +! r = nfa_regexec_both(NULL, col); +! curbuf = save_curbuf; +! +! return r; + } + + #ifdef DEBUG +--- 3840,3846 ---- + #endif + ireg_maxcol = rmp->rmm_maxcol; + +! return nfa_regexec_both(NULL, col); + } + + #ifdef DEBUG +*** ../vim-7.3.998/src/version.c 2013-05-21 20:51:55.000000000 +0200 +--- src/version.c 2013-05-21 21:16:32.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 999, + /**/ + +-- +SOLDIER: Where did you get the coconuts? +ARTHUR: Through ... We found them. +SOLDIER: Found them? In Mercea. The coconut's tropical! + "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// diff --git a/README.patches b/README.patches index 287479e0..b2044a56 100644 --- a/README.patches +++ b/README.patches @@ -1001,7 +1001,7 @@ Individual patches for Vim 7.3: 3304 7.3.967 (after 7.3.965) build fails on Mac OSX 2100 7.3.968 multi-byte support is only available with "big" features 1603 7.3.969 can't built with Python 3 and without Python 2 -184170 7.3.970 pattern matching is slow, include the NFA engine +182647 7.3.970 (fixed) pattern matching is slow, include the NFA engine 4337 7.3.971 no support for VS2012 static code analysis 3720 7.3.972 cursor not restored properly after InsertEnter autocommand 3881 7.3.973 (after 7.3.970) compiler warnings, crash on startup @@ -1019,3 +1019,16 @@ Individual patches for Vim 7.3: 1691 7.3.985 GTK vim not started as gvim has WM_CLASS property wrong 2113 7.3.986 test 95 doesn't pass when 'encoding' isn't utf-8 6338 7.3.987 no easy to run an individual test; test 64 may fail + 1552 7.3.988 new regexp engine is slow + 1944 7.3.989 new regexp engine compares negative numbers to character + 7487 7.3.990 memory leak in new regexp engine + 18482 7.3.991 more can be shared between python 2 and 3 + 70337 7.3.992 Python: Too many type casts + 7832 7.3.993 (after 7.3.992) later patch does things slightly differently + 7845 7.3.994 Python: using magic constants + 13902 7.3.995 Python: Module initialization is duplicated + 14039 7.3.996 Python: Can't check types of what is returned by bindeval() + 23712 7.3.997 Vim and Python exceptions are different + 11177 7.3.998 Python: garbage collection issues + 4683 7.3.999 new regexp engine sets curbuf temporarily + 1637 7.3.1000 (whoa!) typo in char value causes out of bounds access diff --git a/vim.spec b/vim.spec index 87cd16f1..1fa76a45 100644 --- a/vim.spec +++ b/vim.spec @@ -18,7 +18,7 @@ #used for pre-releases: %define beta %{nil} %define vimdir vim73%{?beta} -%define patchlevel 987 +%define patchlevel 1000 Summary: The VIM editor URL: http://www.vim.org/ @@ -1043,6 +1043,19 @@ Patch984: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.984 Patch985: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.985 Patch986: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.986 Patch987: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.987 +Patch988: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.988 +Patch989: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.989 +Patch990: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.990 +Patch991: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.991 +Patch992: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.992 +Patch993: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.993 +Patch994: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.994 +Patch995: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.995 +Patch996: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.996 +Patch997: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.997 +Patch998: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.998 +Patch999: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.999 +Patch1000: ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.1000 Patch3000: vim-7.3-syntax.patch Patch3002: vim-7.1-nowarnings.patch @@ -2177,6 +2190,19 @@ perl -pi -e "s,bin/nawk,bin/awk,g" runtime/tools/mve.awk %patch985 -p0 %patch986 -p0 %patch987 -p0 +%patch988 -p0 +%patch989 -p0 +%patch990 -p0 +%patch991 -p0 +%patch992 -p0 +%patch993 -p0 +%patch994 -p0 +%patch995 -p0 +%patch996 -p0 +%patch997 -p0 +%patch998 -p0 +%patch999 -p0 +%patch1000 -p0 # install spell files @@ -2672,6 +2698,9 @@ rm -rf %{buildroot} %{_datadir}/icons/hicolor/*/apps/* %changelog +* Wed May 22 2013 Karsten Hopp 7.3.1000-1 +- patchlevel 1000 ! + * Tue May 21 2013 Karsten Hopp 7.3.987-1 - patchlevel 987