diff options
author | Tom Tromey <tom@tromey.com> | 2018-12-27 11:53:20 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-01-03 14:49:18 -0700 |
commit | 2a3c71d68d452bb6b06d199d0eb7bc0cbc2b9b25 (patch) | |
tree | b66f2e202a390bbbcfa81c574d5388fcad12d4fa /gdb/python/py-cmd.c | |
parent | 5c329e6ab4c7bba9b83155571b150756210001df (diff) | |
download | gdb-2a3c71d68d452bb6b06d199d0eb7bc0cbc2b9b25.zip gdb-2a3c71d68d452bb6b06d199d0eb7bc0cbc2b9b25.tar.gz gdb-2a3c71d68d452bb6b06d199d0eb7bc0cbc2b9b25.tar.bz2 |
Remove more uses of explicit reference counting in Python
This changes some more place in the Python code to use gdbpy_ref
rather than explicit reference counting. While doing this I found a
latent bug in typy_fields_items -- it was not checking for errors in
one spot. I also changed valpy_dealloc to use Py_XDECREF rather than
an explicit "if".
gdb/ChangeLog
2019-01-03 Tom Tromey <tom@tromey.com>
* python/py-value.c (valpy_dealloc): Use Py_XDECREF.
* python/py-type.c (typy_fields_items): Use gdbpy_ref.
* python/py-progspace.c (pspy_set_printers): Use gdbpy_ref.
(pspy_set_frame_filters, pspy_set_frame_unwinders)
(pspy_set_type_printers): Likewise.
* python/py-function.c (fnpy_init): Use gdbpy_ref.
* python/py-cmd.c (cmdpy_init): Use gdbpy_ref.
* python/py-objfile.c (objfpy_set_printers): Use gdbpy_ref.
(objfpy_set_frame_filters, objfpy_set_frame_unwinders)
(objfpy_set_type_printers): Likewise.
Diffstat (limited to 'gdb/python/py-cmd.c')
-rw-r--r-- | gdb/python/py-cmd.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index 1087a9c..bc18cec 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -540,7 +540,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) if (! docstring) docstring = xstrdup (_("This command is not documented.")); - Py_INCREF (self); + gdbpy_ref<> self_ref = gdbpy_ref<>::new_reference (self); TRY { @@ -566,7 +566,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) cmd->destroyer = cmdpy_destroyer; obj->command = cmd; - set_cmd_context (cmd, self); + set_cmd_context (cmd, self_ref.release ()); set_cmd_completer (cmd, ((completetype == -1) ? cmdpy_completer : completers[completetype].completer)); if (completetype == -1) @@ -578,7 +578,6 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) xfree (cmd_name); xfree (docstring); xfree (pfx_name); - Py_DECREF (self); gdbpy_convert_exception (except); return -1; } |