updated for version 7.3.1236
Problem: Python: WindowSetattr() missing support for NUMBER_UNSIGNED.
Solution: Add NUMBER_UNSIGNED, add more tests. Various fixes. (ZyX)
diff --git a/src/if_py_both.h b/src/if_py_both.h
index 706794c..8f60550 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -1611,7 +1611,7 @@
ret = (rObj == Py_True);
- Py_DECREF(Py_True);
+ Py_DECREF(rObj);
return ret;
}
@@ -1910,7 +1910,7 @@
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 @@
clear_tv(&v);
}
Py_DECREF(iterator);
+
+ if (PyErr_Occurred())
+ return -1;
+
return 0;
}
@@ -3361,7 +3365,7 @@
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 @@
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 @@
char *str;
char *save;
PyObject *bytes = NULL;
- Py_ssize_t len;
+ Py_ssize_t len = 0;
PyInt i;
char *p;
@@ -5483,6 +5487,7 @@
#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 @@
{"_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 @@
}
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 @@
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 @@
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))
{