aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/python-internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/python-internal.h')
-rw-r--r--gdb/python/python-internal.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 65d2eee38ed..95619bf775e 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -1157,6 +1157,9 @@ public:
using obj_type = typename Storage::obj_type;
using val_type = typename Storage::val_type;
+ static_assert(std::is_base_of<PyObject, obj_type>::value,
+ "obj_type must be a subclass of PyObject");
+
/* Register Python object OBJ as being "owned" by OWNER. When OWNER is
about to be freed, OBJ will be invalidated. */
template <typename O>
@@ -1180,7 +1183,7 @@ public:
obj_type *lookup (O *owner, val_type *val) const
{
obj_type *obj = get_storage (owner)->lookup (val);
- Py_XINCREF (obj);
+ Py_XINCREF (static_cast<PyObject *> (obj));
return obj;
}