Prior art includes g_clear_error in GLib, and Py_CLEAR in CPython. I'm happy to omit the two commits "configure.ac: check for an optional C++ compiler" and "tests/util-cxx.cpp: check that tp_clear_pointer works..." if reviewers don't feel that they add enough value. The commit "Use tp_clear_object, tp_clear_pointer in tests" replaces test_clear_object, CLEAR_OBJECT, CLEAR_BOXED and CLEAR_HASH, but does not attempt to use the new macros in every situation where they'd be a code reduction. Similarly, the commit "Use tp_clear_object, tp_clear_pointer in various places" is not intended to be exhaustive. I think we should encourage these macros in new code, but not put a lot of effort into replacing existing code with them, much like g_clear_error.
I for one don't really understand the code you compile in the configure.ac check for a C++ compiler.
(In reply to comment #1) > I for one don't really understand the code you compile in the configure.ac > check for a C++ compiler. + [[#include <gio/gio.h>]], This part goes before main(), + [[g_type_init (); g_object_unref (g_file_new_for_path ("/"));]]) and this part is the body of main() - it just checks that we a C++ program can link to GIO, from which I use GFile as a convenient easy-to-instantiate GObject in the test.
(In reply to comment #2) > + [[g_type_init (); g_object_unref (g_file_new_for_path ("/"));]]) > > and this part is the body of main() - it just checks that we a C++ program can > link to GIO, from which I use GFile as a convenient easy-to-instantiate GObject > in the test. Okay, I wondered if there was any particular significance to this code. Then this branch seems fine. (I'd really prefer these were in GLib, though.)
(In reply to comment #3) > Okay, I wondered if there was any particular significance to this code. Then > this branch seems fine. (I'd really prefer these were in GLib, though.) Thanks. I'll open a GLib bug once I've merged these.
Fixed in git for 0.11.7. Also proposed for GLib: https://bugzilla.gnome.org/show_bug.cgi?id=620263
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.