diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-06-23 16:35:47 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-06-23 16:35:47 +0200 |
commit | dee2e315d786cbe9d5bba2d388fb72d96ad1a846 (patch) | |
tree | 3a8548edebc6f07c6b08a3d2017dcb877f351bb4 /src/if_py_both.h | |
parent | ede3e6383d0bc86c13f039e9013ff72e307937d2 (diff) |
updated for version 7.3.1236v7.3.1236
Problem: Python: WindowSetattr() missing support for NUMBER_UNSIGNED.
Solution: Add NUMBER_UNSIGNED, add more tests. Various fixes. (ZyX)
Diffstat (limited to 'src/if_py_both.h')
-rw-r--r-- | src/if_py_both.h | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/if_py_both.h b/src/if_py_both.h index 706794cc5f..8f60550f93 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -1611,7 +1611,7 @@ DictionaryContains(DictionaryObject *self, PyObject *keyObject) ret = (rObj == Py_True); - Py_DECREF(Py_True); + Py_DECREF(rObj); return ret; } @@ -1910,7 +1910,7 @@ DictionaryUpdate(DictionaryObject *self, PyObject *args, PyObject *kwargs) PyErr_FORMAT(PyExc_ValueError, N_("expected sequence element of size 2, " "but got sequence of size %d"), - PySequence_Fast_GET_SIZE(fast)); + (int) PySequence_Fast_GET_SIZE(fast)); return NULL; } @@ -2435,6 +2435,10 @@ ListAssSlice(ListObject *self, Py_ssize_t first, Py_ssize_t last, PyObject *obj) clear_tv(&v); } Py_DECREF(iterator); + + if (PyErr_Occurred()) + return -1; + return 0; } @@ -3361,7 +3365,7 @@ WindowSetattr(WindowObject *self, char *name, PyObject *valObject) long height; win_T *savewin; - if (NumberToLong(valObject, &height, NUMBER_INT)) + if (NumberToLong(valObject, &height, NUMBER_INT|NUMBER_UNSIGNED)) return -1; #ifdef FEAT_GUI @@ -3384,7 +3388,7 @@ WindowSetattr(WindowObject *self, char *name, PyObject *valObject) long width; win_T *savewin; - if (NumberToLong(valObject, &width, NUMBER_INT)) + if (NumberToLong(valObject, &width, NUMBER_INT|NUMBER_UNSIGNED)) return -1; #ifdef FEAT_GUI @@ -3518,7 +3522,7 @@ StringToLine(PyObject *obj) char *str; char *save; PyObject *bytes = NULL; - Py_ssize_t len; + Py_ssize_t len = 0; PyInt i; char *p; @@ -5483,6 +5487,7 @@ _ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookup_dict) #endif else if (PyObject_HasAttrString(obj, "keys")) return convert_dl(obj, tv, pymap_to_tv, lookup_dict); + /* PyObject_GetIter can create built-in iterator for any sequence object */ else if (PyIter_Check(obj) || PySequence_Check(obj)) return convert_dl(obj, tv, pyseq_to_tv, lookup_dict); else if (PyMapping_Check(obj)) @@ -5930,11 +5935,8 @@ static struct object_constant { {"_Loader", (PyObject *)&LoaderType}, }; -typedef int (*object_adder)(PyObject *, const char *, PyObject *); -typedef PyObject *(*attr_getter)(PyObject *, const char *); - #define ADD_OBJECT(m, name, obj) \ - if (add_object(m, name, obj)) \ + if (PyModule_AddObject(m, name, obj)) \ return -1; #define ADD_CHECKED_OBJECT(m, name, obj) \ @@ -5946,7 +5948,7 @@ typedef PyObject *(*attr_getter)(PyObject *, const char *); } static int -populate_module(PyObject *m, object_adder add_object, attr_getter get_attr) +populate_module(PyObject *m) { int i; PyObject *other_module; @@ -5990,7 +5992,7 @@ populate_module(PyObject *m, object_adder add_object, attr_getter get_attr) if (!(py_chdir = PyObject_GetAttrString(other_module, "chdir"))) return -1; ADD_OBJECT(m, "_chdir", py_chdir); - if (!(attr = get_attr(m, "chdir"))) + if (!(attr = PyObject_GetAttrString(m, "chdir"))) return -1; if (PyObject_SetAttrString(other_module, "chdir", attr)) { @@ -6002,7 +6004,7 @@ populate_module(PyObject *m, object_adder add_object, attr_getter get_attr) if ((py_fchdir = PyObject_GetAttrString(other_module, "fchdir"))) { ADD_OBJECT(m, "_fchdir", py_fchdir); - if (!(attr = get_attr(m, "fchdir"))) + if (!(attr = PyObject_GetAttrString(m, "fchdir"))) return -1; if (PyObject_SetAttrString(other_module, "fchdir", attr)) { |