)]}'
{
  "commit": "37f5e02ef5be1ba47e80df4af690df26ee1dac83",
  "tree": "3f61a9ecc82299f3d45b7d76f78aa9e7568c8c60",
  "parents": [
    "bd7a2f22b11e37ce35c3a78f6fb54ef74270b903"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Tue Apr 22 19:56:13 2025 +0100"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Wed Apr 23 15:46:22 2025 +0100"
  },
  "message": "gdb/python: don\u0027t use PyObject_IsInstance in gdbpy_is_color\n\nThe gdbpy_is_color function uses PyObject_IsInstance, and converts the\nreturn from PyObject_IsInstance to a bool.\n\nUnfortunately, PyObject_IsInstance can return -1, 0, or 1, for error,\nfailure, or success respectively.  When converting to a bool both -1\nand 1 will convert to true.\n\nAdditionally, when PyObject_IsInstance returns -1 an error will be\nset.\n\nWhat this means is that, if gdbpy_is_color is called with a non\ngdb.Color object, and the PyObject_IsInstance check raises an error,\nthen (a) GDB will continue as if the object is a gdb.Color object,\nwhich is likely going to invoke undefined behaviour, see\ngdbpy_get_color for example, and (b) when GDB eventually returns to\nthe Python interpreter, due to an error being set, we\u0027ll see:\n\n  Python Exception \u003cclass \u0027SystemError\u0027\u003e: PyEval_EvalFrameEx returned a result with an error set\n  Error occurred in Python: PyEval_EvalFrameEx returned a result with an error set\n\nHowever, after the previous commit, gdb.Color can no longer be\nsub-classed, this means that fixing the above problems is easy, we can\nreplace the PyObject_IsInstance check with a PyObject_TypeCheck, the\nPyObject_TypeCheck function only returns 0 or 1, there\u0027s no -1 error\ncase.\n\nIt\u0027s also worth noting that PyObject_TypeCheck is the function that is\nmore commonly used within GDB\u0027s Python API implementation, include the\npy-color.c use there were only 4 PyObject_IsInstance uses.  Of the\nremaining 3, 2 are fine, and one other (in py-disasm.c) is also\nwrong.  I\u0027ll address that in a separate patch.\n\nThere\u0027s also a new test included which exposes the above issue.\n\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "fb4b80e41cc8de0e419795ff545a37634931c5ba",
      "old_mode": 33188,
      "old_path": "gdb/python/py-color.c",
      "new_id": "c48d14e1418ee2202b0c2d0539f4dc26ddf3ac56",
      "new_mode": 33188,
      "new_path": "gdb/python/py-color.c"
    },
    {
      "type": "modify",
      "old_id": "88967d4d43ea5f5708f3253c99e17a366b649609",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.python/py-color.exp",
      "new_id": "99b4689028990df098ca2e2279541bf5e64d2854",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.python/py-color.exp"
    }
  ]
}
