aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2025-04-22 18:01:07 +0100
committerAndrew Burgess <aburgess@redhat.com>2025-04-23 15:46:22 +0100
commitbd7a2f22b11e37ce35c3a78f6fb54ef74270b903 (patch)
tree648bf05447ae30e8e12a7dfeb071499f46a64188 /gdb/testsuite/gdb.python
parentdff7f6c72d05d8a378dc346e6900ba7c4eba759f (diff)
downloadbinutils-bd7a2f22b11e37ce35c3a78f6fb54ef74270b903.zip
binutils-bd7a2f22b11e37ce35c3a78f6fb54ef74270b903.tar.gz
binutils-bd7a2f22b11e37ce35c3a78f6fb54ef74270b903.tar.bz2
gdb/python: remove Py_TPFLAGS_BASETYPE from gdb.Color
Remove the Py_TPFLAGS_BASETYPE flag from the gdb.Color type. This effectively makes gdb.Color final; users can no longer create classes that inherit from gdb.Color. Right now I cannot think of any cases where inheritance would be needed over composition for a simple type like gdb.Color. If I'm wrong, then it's easy to add Py_TPFLAGS_BASETYPE back in later, this would be an extension of the API. But it's much harder to remove the flag later as that might break existing user code (note: there has been no release of GDB yet that includes the gdb.Color type). Introducing this restriction makes the next commit easier. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r--gdb/testsuite/gdb.python/py-color.exp10
1 files changed, 10 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-color.exp b/gdb/testsuite/gdb.python/py-color.exp
index 1b8e0c5..88967d4 100644
--- a/gdb/testsuite/gdb.python/py-color.exp
+++ b/gdb/testsuite/gdb.python/py-color.exp
@@ -97,3 +97,13 @@ gdb_test [concat "python print (c_red.escape_sequence (True) + " \
"\033\\\[31m\033\\\[42mred on green\033\\\[49m red on default\033\\\[39m" \
"escape sequences"
+gdb_test_multiline "Try to sub-class gdb.Color" \
+ "python" "" \
+ "class my_color(gdb.Color):" "" \
+ " def __init__(self):" "" \
+ " super().__init__('red')" "" \
+ "end" \
+ [multi_line \
+ "Python Exception <class 'TypeError'>: type 'gdb\\.Color' is not an acceptable base type" \
+ "Error occurred in Python: type 'gdb\\.Color' is not an acceptable base type"]
+