diff src/if_py_both.h @ 4982:39980afcf54a v7.3.1236

updated for version 7.3.1236 Problem: Python: WindowSetattr() missing support for NUMBER_UNSIGNED. Solution: Add NUMBER_UNSIGNED, add more tests. Various fixes. (ZyX)
author Bram Moolenaar <bram@vim.org>
date Sun, 23 Jun 2013 16:35:47 +0200
parents f4969f8f66e9
children 5b2c8f3b3906
line wrap: on
line diff
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -1611,7 +1611,7 @@ DictionaryContains(DictionaryObject *sel
 
     ret = (rObj == Py_True);
 
-    Py_DECREF(Py_True);
+    Py_DECREF(rObj);
 
     return ret;
 }
@@ -1910,7 +1910,7 @@ DictionaryUpdate(DictionaryObject *self,
 		    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_
 	clear_tv(&v);
     }
     Py_DECREF(iterator);
+
+    if (PyErr_Occurred())
+	return -1;
+
     return 0;
 }
 
@@ -3361,7 +3365,7 @@ WindowSetattr(WindowObject *self, char *
 	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 *
 	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, typva
 #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)(PyObjec
     }
 
     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_adde
     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_adde
     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))
 	{