From: Tom Tromey Date: Sat, 21 Feb 2026 17:05:24 +0000 (-0700) Subject: Don't use template for gdbpy_ref_policy X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0d9faae86e6fadd0cae08fc29424551de458fefc;p=thirdparty%2Fbinutils-gdb.git Don't use template for gdbpy_ref_policy Now that gdb's Python types derive from PyObject, there's no need to use a template for gdbpy_ref_policy. This simplifies the code a tiny bit. Approved-By: Andrew Burgess --- diff --git a/gdb/python/py-ref.h b/gdb/python/py-ref.h index 4ce7e29357d..0a56436634d 100644 --- a/gdb/python/py-ref.h +++ b/gdb/python/py-ref.h @@ -23,27 +23,23 @@ #include "gdbsupport/gdb_ref_ptr.h" /* A policy class for gdb::ref_ptr for Python reference counting. */ -template struct gdbpy_ref_policy { - static_assert(std::is_base_of::value, - "T must be a subclass of PyObject"); - - static void incref (T *ptr) + static void incref (PyObject *ptr) { - Py_INCREF (static_cast (ptr)); + Py_INCREF (ptr); } - static void decref (T *ptr) + static void decref (PyObject *ptr) { - Py_DECREF (static_cast (ptr)); + Py_DECREF (ptr); } }; /* A gdb::ref_ptr that has been specialized for Python objects or their "subclasses". */ template using gdbpy_ref - = gdb::ref_ptr>; + = gdb::ref_ptr; /* A wrapper class for Python extension objects that have a __dict__ attribute.