From 02c95291c3eadf0cfc601286eb92cbb7efceb517 Mon Sep 17 00:00:00 2001 From: Elias Bachaalany Date: Thu, 12 Jan 2023 21:27:42 -0800 Subject: [PATCH] + bugfix: IDAPython: Choose.OnGetLineAttr was broken - It was only accepting lists (it should accept both tuples and lists) --- pywraps/py_kernwin_choose.hpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pywraps/py_kernwin_choose.hpp b/pywraps/py_kernwin_choose.hpp index f25fb11..52d38fd 100644 --- a/pywraps/py_kernwin_choose.hpp +++ b/pywraps/py_kernwin_choose.hpp @@ -478,15 +478,18 @@ void py_chooser_mixin_t::mixin_get_row( PyObject_CallMethod( self.o, (char *)S_ON_GET_LINE_ATTR, "i", int(n))); - if ( PyErr_Occurred() != nullptr ) - return; - if ( pyres.result != nullptr && PyList_Check(pyres.result.o) ) + if ( PyErr_Occurred() == nullptr && pyres.result != nullptr && PySequence_Check(pyres.result.o) ) { - PyObject *item; - if ( (item = PyList_GetItem(pyres.result.o, 0)) != nullptr ) - attrs->color = PyInt_AsLong(item); - if ( (item = PyList_GetItem(pyres.result.o, 1)) != nullptr ) - attrs->flags = PyInt_AsLong(item); + { + newref_t item(PySequence_GetItem(pyres.result.o, 0)); + if (item.o != nullptr && PyLong_Check(item.o)) + attrs->color = PyLong_AsUnsignedLong(item.o); + } + { + newref_t item(PySequence_GetItem(pyres.result.o, 1)); + if (item.o != nullptr && PyLong_Check(item.o)) + attrs->flags = PyInt_AsLong(item.o); + } } } }