From 0d9faae86e6fadd0cae08fc29424551de458fefc Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 21 Feb 2026 10:05:24 -0700 Subject: 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 --- gdb/python/py-ref.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'gdb/python') 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. -- cgit v1.2.3