)]}'
{
  "commit": "935dc9ff652ca256c10672412c1df3da95cadbfb",
  "tree": "33bda9adff1104c207ef6194840f60cdd5cb7292",
  "parents": [
    "cd51849c90e8fd13779bec69f5d4c7aadf03a532"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Thu Nov 16 14:42:56 2023 +0000"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Mon Nov 27 15:44:45 2023 +0000"
  },
  "message": "gdb/python: handle completion returning a non-sequence\n\nGDB\u0027s Python API documentation for gdb.Command.complete() says:\n\n  The \u0027complete\u0027 method can return several values:\n     * If the return value is a sequence, the contents of the\n       sequence are used as the completions.  It is up to \u0027complete\u0027\n       to ensure that the contents actually do complete the word.  A\n       zero-length sequence is allowed, it means that there were no\n       completions available.  Only string elements of the sequence\n       are used; other elements in the sequence are ignored.\n\n     * If the return value is one of the \u0027COMPLETE_\u0027 constants\n       defined below, then the corresponding GDB-internal completion\n       function is invoked, and its result is used.\n\n     * All other results are treated as though there were no\n       available completions.\n\nSo, returning a non-sequence, and non-integer from a complete method\nshould be fine; it should just be treated as though there are no\ncompletions.\n\nHowever, if I write a complete method that returns None, I see this\nbehaviour:\n\n  (gdb) complete completefilenone x\n  Python Exception \u003cclass \u0027TypeError\u0027\u003e: \u0027NoneType\u0027 object is not iterable\n  warning: internal error: Unhandled Python exception\n  (gdb)\n\nWhich is caused because we currently assume that anything that is not\nan integer must be iterable, and we call PyObject_GetIter on it.  When\nthis call fails a Python exception is set, but instead of\nclearing (and therefore ignoring) this exception as we do everywhere\nelse in the Python completion code, we instead just return with the\nexception set.\n\nIn this commit I add a PySequence_Check call.  If this call returns\nfalse (and we\u0027ve already checked the integer case) then we can assume\nthere are no completion results.\n\nI\u0027ve added a test which checks returning a non-sequence.\n\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "20a384d690747a4a330a4a9bfcdfaaf3f8d85d3a",
      "old_mode": 33188,
      "old_path": "gdb/python/py-cmd.c",
      "new_id": "d3845fc7509e543a781e6b89031229986caa3a00",
      "new_mode": 33188,
      "new_path": "gdb/python/py-cmd.c"
    },
    {
      "type": "modify",
      "old_id": "23f981e944a71f6df455fbbbbb9f5e79fafabdf3",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.python/py-completion.exp",
      "new_id": "89843c96f1fc53cf1333e6f1511ccedf9e0120dc",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.python/py-completion.exp"
    },
    {
      "type": "modify",
      "old_id": "abec06921c0e24fd5f6b17d3b82d58c81768a163",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.python/py-completion.py",
      "new_id": "61b6beffa25628a7a615d7ea0ccfca1233a32ee0",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.python/py-completion.py"
    }
  ]
}
