patch 9.1.1251: if_python: build error with tuples and dynamic python

Commit: 
https://github.com/vim/vim/commit/e06b2aea437f44a9fe4ac685667b5f4c89904dc8
Author: Yee Cheng Chin <ychin....@gmail.com>
Date:   Thu Mar 27 20:13:33 2025 +0100

    patch 9.1.1251: if_python: build error with tuples and dynamic python
    
    Problem:  if_python: build error with tuples and dynamic python
              (after v9.1.1239)
    Solution: Fix build error and test failures (Yee Cheng Cin)
    
    closes: #16992
    
    Co-authored-by: Yegappan Lakshmanan <yegap...@yahoo.com>
    Signed-off-by: Yee Cheng Chin <ychin....@gmail.com>
    Signed-off-by: Yegappan Lakshmanan <yegap...@yahoo.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/if_py_both.h b/src/if_py_both.h
index 641c1594a..ed66254ff 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -1097,12 +1097,6 @@ VimToPython(typval_T *our_tv, int depth, PyObject 
*lookup_dict)
        if (ret == NULL)
            return NULL;
 
-       if (PyDict_SetItemString(lookup_dict, ptrBuf, ret))
-       {
-           Py_DECREF(ret);
-           return NULL;
-       }
-
        for (int idx = 0; idx < len; idx++)
        {
            typval_T    *item_tv = TUPLE_ITEM(tuple, idx);
@@ -1113,7 +1107,13 @@ VimToPython(typval_T *our_tv, int depth, PyObject 
*lookup_dict)
                Py_DECREF(ret);
                return NULL;
            }
-           PyTuple_SET_ITEM(ret, idx, newObj);
+           PyTuple_SetItem(ret, idx, newObj);
+       }
+
+       if (PyDict_SetItemString(lookup_dict, ptrBuf, ret))
+       {
+           Py_DECREF(ret);
+           return NULL;
        }
     }
     else if (our_tv->v_type == VAR_DICT)
@@ -3440,7 +3440,7 @@ TupleSlice(
            return NULL;
        }
 
-       PyTuple_SET_ITEM(tuple, i, item);
+       PyTuple_SetItem(tuple, i, item);
     }
 
     return tuple;
diff --git a/src/if_python.c b/src/if_python.c
index 594d7e5bd..5a5e6ea30 100644
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -202,6 +202,7 @@ struct PyMethodDef { Py_ssize_t a; };
 # define PyList_Size dll_PyList_Size
 # define PyList_Type (*dll_PyList_Type)
 # define PyTuple_GetItem dll_PyTuple_GetItem
+# define PyTuple_SetItem dll_PyTuple_SetItem
 # define PyTuple_New dll_PyTuple_New
 # define PyTuple_Size dll_PyTuple_Size
 # define PyTuple_Type (*dll_PyTuple_Type)
@@ -358,7 +359,6 @@ static PyInt(*dll_PyList_Size)(PyObject *);
 static PyTypeObject* dll_PyList_Type;
 static PyObject*(*dll_PyTuple_GetItem)(PyObject *, PyInt);
 static int(*dll_PyTuple_SetItem)(PyObject *, PyInt, PyObject *);
-static int(*dll_PyTuple_SET_ITEM)(PyObject *, PyInt, PyObject *);
 static PyObject*(*dll_PyTuple_New)(PyInt size);
 static PyInt(*dll_PyTuple_Size)(PyObject *);
 static PyTypeObject* dll_PyTuple_Type;
@@ -549,7 +549,6 @@ static struct
     {"PyList_Type", (PYTHON_PROC*)&dll_PyList_Type},
     {"PyTuple_GetItem", (PYTHON_PROC*)&dll_PyTuple_GetItem},
     {"PyTuple_SetItem", (PYTHON_PROC*)&dll_PyTuple_SetItem},
-    {"PyTuple_SET_ITEM", (PYTHON_PROC*)&dll_PyTuple_SET_ITEM},
     {"PyTuple_New", (PYTHON_PROC*)&dll_PyTuple_New},
     {"PyTuple_Size", (PYTHON_PROC*)&dll_PyTuple_Size},
     {"PyTuple_Type", (PYTHON_PROC*)&dll_PyTuple_Type},
diff --git a/src/if_python3.c b/src/if_python3.c
index b2eb1d473..8b94e073e 100644
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -190,8 +190,6 @@ static HINSTANCE hinstPy3 = 0; // Instance of python.dll
 # define PyTuple_New py3_PyTuple_New
 # define PyTuple_GetItem py3_PyTuple_GetItem
 # define PyTuple_SetItem py3_PyTuple_SetItem
-# undef PyTuple_SET_ITEM
-# define PyTuple_SET_ITEM py3_PyTuple_SET_ITEM
 # define PyTuple_Size py3_PyTuple_Size
 # define PySequence_Check py3_PySequence_Check
 # define PySequence_Size py3_PySequence_Size
@@ -377,7 +375,6 @@ static int (*py3_PyList_Insert)(PyObject *, int, PyObject 
*);
 static Py_ssize_t (*py3_PyList_Size)(PyObject *);
 static PyObject* (*py3_PyTuple_New)(Py_ssize_t size);
 static int (*py3_PyTuple_SetItem)(PyObject *, Py_ssize_t, PyObject *);
-static int (*py3_PyTuple_SET_ITEM)(PyObject *, Py_ssize_t, PyObject *);
 static Py_ssize_t (*py3_PyTuple_Size)(PyObject *);
 static int (*py3_PySequence_Check)(PyObject *);
 static Py_ssize_t (*py3_PySequence_Size)(PyObject *);
@@ -595,7 +592,6 @@ static struct
     {"PyTuple_New", (PYTHON_PROC*)&py3_PyTuple_New},
     {"PyTuple_GetItem", (PYTHON_PROC*)&py3_PyTuple_GetItem},
     {"PyTuple_SetItem", (PYTHON_PROC*)&py3_PyTuple_SetItem},
-    {"PyTuple_SET_ITEM", (PYTHON_PROC*)&py3_PyTuple_SET_ITEM},
     {"PyTuple_Size", (PYTHON_PROC*)&py3_PyTuple_Size},
     {"PySequence_Check", (PYTHON_PROC*)&py3_PySequence_Check},
     {"PySequence_Size", (PYTHON_PROC*)&py3_PySequence_Size},
diff --git a/src/version.c b/src/version.c
index cb559cfd8..a40a1870d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1251,
 /**/
     1250,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1txsvT-001nak-VB%40256bit.org.

Raspunde prin e-mail lui