/* Implementation of the GDB variable objects API.
- Copyright (C) 1999-2018 Free Software Foundation, Inc.
+ Copyright (C) 1999-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#if HAVE_PYTHON
#include "python/python.h"
#include "python/python-internal.h"
-#include "python/py-ref.h"
#else
typedef int PyObject;
#endif
if (pretty_printing)
{
- PyObject *pretty_printer = NULL;
+ gdbpy_ref<> pretty_printer;
if (var->value != nullptr)
{
pretty_printer = gdbpy_get_varobj_pretty_printer (var->value.get ());
- if (! pretty_printer)
+ if (pretty_printer == nullptr)
{
gdbpy_print_stack ();
error (_("Cannot instantiate printer for default visualizer"));
}
}
-
+
if (pretty_printer == Py_None)
- {
- Py_DECREF (pretty_printer);
- pretty_printer = NULL;
- }
+ pretty_printer.release ();
- install_visualizer (var->dynamic, NULL, pretty_printer);
+ install_visualizer (var->dynamic, NULL, pretty_printer.release ());
}
}