Skip to content

Commit 92bef72

Browse files
committed
updated for version 7.3.1236
Problem: Python: WindowSetattr() missing support for NUMBER_UNSIGNED. Solution: Add NUMBER_UNSIGNED, add more tests. Various fixes. (ZyX)
1 parent 794b3d6 commit 92bef72

File tree

14 files changed

+549
-225
lines changed

14 files changed

+549
-225
lines changed

src/if_py_both.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ DictionaryContains(DictionaryObject *self, PyObject *keyObject)
16111611

16121612
ret = (rObj == Py_True);
16131613

1614-
Py_DECREF(Py_True);
1614+
Py_DECREF(rObj);
16151615

16161616
return ret;
16171617
}
@@ -1910,7 +1910,7 @@ DictionaryUpdate(DictionaryObject *self, PyObject *args, PyObject *kwargs)
19101910
PyErr_FORMAT(PyExc_ValueError,
19111911
N_("expected sequence element of size 2, "
19121912
"but got sequence of size %d"),
1913-
PySequence_Fast_GET_SIZE(fast));
1913+
(int) PySequence_Fast_GET_SIZE(fast));
19141914
return NULL;
19151915
}
19161916

@@ -2435,6 +2435,10 @@ ListAssSlice(ListObject *self, Py_ssize_t first, Py_ssize_t last, PyObject *obj)
24352435
clear_tv(&v);
24362436
}
24372437
Py_DECREF(iterator);
2438+
2439+
if (PyErr_Occurred())
2440+
return -1;
2441+
24382442
return 0;
24392443
}
24402444

@@ -3361,7 +3365,7 @@ WindowSetattr(WindowObject *self, char *name, PyObject *valObject)
33613365
long height;
33623366
win_T *savewin;
33633367

3364-
if (NumberToLong(valObject, &height, NUMBER_INT))
3368+
if (NumberToLong(valObject, &height, NUMBER_INT|NUMBER_UNSIGNED))
33653369
return -1;
33663370

33673371
#ifdef FEAT_GUI
@@ -3384,7 +3388,7 @@ WindowSetattr(WindowObject *self, char *name, PyObject *valObject)
33843388
long width;
33853389
win_T *savewin;
33863390

3387-
if (NumberToLong(valObject, &width, NUMBER_INT))
3391+
if (NumberToLong(valObject, &width, NUMBER_INT|NUMBER_UNSIGNED))
33883392
return -1;
33893393

33903394
#ifdef FEAT_GUI
@@ -3518,7 +3522,7 @@ StringToLine(PyObject *obj)
35183522
char *str;
35193523
char *save;
35203524
PyObject *bytes = NULL;
3521-
Py_ssize_t len;
3525+
Py_ssize_t len = 0;
35223526
PyInt i;
35233527
char *p;
35243528

@@ -5483,6 +5487,7 @@ _ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookup_dict)
54835487
#endif
54845488
else if (PyObject_HasAttrString(obj, "keys"))
54855489
return convert_dl(obj, tv, pymap_to_tv, lookup_dict);
5490+
/* PyObject_GetIter can create built-in iterator for any sequence object */
54865491
else if (PyIter_Check(obj) || PySequence_Check(obj))
54875492
return convert_dl(obj, tv, pyseq_to_tv, lookup_dict);
54885493
else if (PyMapping_Check(obj))
@@ -5930,11 +5935,8 @@ static struct object_constant {
59305935
{"_Loader", (PyObject *)&LoaderType},
59315936
};
59325937

5933-
typedef int (*object_adder)(PyObject *, const char *, PyObject *);
5934-
typedef PyObject *(*attr_getter)(PyObject *, const char *);
5935-
59365938
#define ADD_OBJECT(m, name, obj) \
5937-
if (add_object(m, name, obj)) \
5939+
if (PyModule_AddObject(m, name, obj)) \
59385940
return -1;
59395941

59405942
#define ADD_CHECKED_OBJECT(m, name, obj) \
@@ -5946,7 +5948,7 @@ typedef PyObject *(*attr_getter)(PyObject *, const char *);
59465948
}
59475949

59485950
static int
5949-
populate_module(PyObject *m, object_adder add_object, attr_getter get_attr)
5951+
populate_module(PyObject *m)
59505952
{
59515953
int i;
59525954
PyObject *other_module;
@@ -5990,7 +5992,7 @@ populate_module(PyObject *m, object_adder add_object, attr_getter get_attr)
59905992
if (!(py_chdir = PyObject_GetAttrString(other_module, "chdir")))
59915993
return -1;
59925994
ADD_OBJECT(m, "_chdir", py_chdir);
5993-
if (!(attr = get_attr(m, "chdir")))
5995+
if (!(attr = PyObject_GetAttrString(m, "chdir")))
59945996
return -1;
59955997
if (PyObject_SetAttrString(other_module, "chdir", attr))
59965998
{
@@ -6002,7 +6004,7 @@ populate_module(PyObject *m, object_adder add_object, attr_getter get_attr)
60026004
if ((py_fchdir = PyObject_GetAttrString(other_module, "fchdir")))
60036005
{
60046006
ADD_OBJECT(m, "_fchdir", py_fchdir);
6005-
if (!(attr = get_attr(m, "fchdir")))
6007+
if (!(attr = PyObject_GetAttrString(m, "fchdir")))
60066008
return -1;
60076009
if (PyObject_SetAttrString(other_module, "fchdir", attr))
60086010
{

src/if_python.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,8 +1404,7 @@ PythonMod_Init(void)
14041404
vim_module = Py_InitModule4("vim", VimMethods, (char *)NULL,
14051405
(PyObject *)NULL, PYTHON_API_VERSION);
14061406

1407-
if (populate_module(vim_module, PyModule_AddObject,
1408-
PyObject_GetAttrString))
1407+
if (populate_module(vim_module))
14091408
return -1;
14101409

14111410
if (init_sys_path())

src/if_python3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,7 @@ Py3Init_vim(void)
16231623
if ((vim_module = PyModule_Create(&vimmodule)) == NULL)
16241624
return NULL;
16251625

1626-
if (populate_module(vim_module, PyModule_AddObject, PyObject_GetAttrString))
1626+
if (populate_module(vim_module))
16271627
return NULL;
16281628

16291629
if (init_sys_path())

src/testdir/pythonx/failing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
raise NotImplementedError
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
raise ImportError
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#

0 commit comments

Comments
 (0)