Description: _dirstate_helpers_pyx.pyx: fix tuple casting logic
 Previously this was done implicitly, but now you have to do it manually
Author: Zixing Liu <liushuyu011@gmail.com>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1099121
Forwarded: not-needed
Last-Update: 2025-03-23
---
Index: breezy/breezy/bzr/_dirstate_helpers_pyx.pyx
===================================================================
--- breezy.orig/breezy/bzr/_dirstate_helpers_pyx.pyx
+++ breezy/breezy/bzr/_dirstate_helpers_pyx.pyx
@@ -100,6 +100,10 @@ cdef extern from "Python.h":
     object PyTuple_GetItem_void_object "PyTuple_GET_ITEM" (void* tpl, int index)
     object PyTuple_GET_ITEM(object tpl, Py_ssize_t index)
 
+    PyObject *PyDict_GetItemString(PyObject *dict, char *key)
+    PyObject *PyEval_GetBuiltins()
+    object PyObject_CallOneArg_obj "PyObject_CallOneArg" (PyObject *c, PyObject *a1)
+
     unsigned long PyInt_AsUnsignedLongMask(object number) except? -1
 
     char *PyBytes_AsString(object p)
@@ -846,13 +850,14 @@ cpdef update_entry(self, entry, abspath, stat_value):
         return None
     packed_stat = _pack_stat(stat_value)
     details = PyList_GetItem_void_void(PyTuple_GetItem_void_void(<void *>entry, 1), 0)
-    saved_minikind = PyBytes_AsString_obj(<PyObject *>PyTuple_GetItem_void_void(details, 0))[0]
+    details_tuple = PyObject_CallOneArg_obj(PyDict_GetItemString(PyEval_GetBuiltins(), "tuple"), <PyObject *>details)
+    saved_minikind = PyBytes_AsString(PyTuple_GET_ITEM(details_tuple, 0))[0]
     if minikind == b'd' and saved_minikind == b't':
         minikind = b't'
-    saved_link_or_sha1 = PyTuple_GetItem_void_object(details, 1)
-    saved_file_size = PyTuple_GetItem_void_object(details, 2)
-    saved_executable = PyTuple_GetItem_void_object(details, 3)
-    saved_packed_stat = PyTuple_GetItem_void_object(details, 4)
+    saved_link_or_sha1 = PyTuple_GET_ITEM(details_tuple, 1)
+    saved_file_size = PyTuple_GET_ITEM(details_tuple, 2)
+    saved_executable = PyTuple_GET_ITEM(details_tuple, 3)
+    saved_packed_stat = PyTuple_GET_ITEM(details_tuple, 4)
     # Deal with pyrex decrefing the objects
     Py_INCREF(saved_link_or_sha1)
     Py_INCREF(saved_file_size)
