Bug 19864

Summary: Subclassing gdb.Value with additional arguments produces a Type Error
Product: gdb Reporter: m.lam
Component: pythonAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: m.lam, ssbssa
Priority: P2    
Version: 7.7   
Target Milestone: 12.1   
Host: Target:
Build: Last reconfirmed:
Attachments: Example script to reproduce issue

Description m.lam 2016-03-24 20:31:38 UTC
Created attachment 9128 [details]
Example script to reproduce issue

Overview
When subclassing gdb.Value in Python, adding additional arguments to the __init__() method causes a "TypeError: Value object creation takes only 1 argument."  This error is not a normal Python error, as it doesn't contain the information on the number of arguments passed to it.

Steps to reproduce
1.Run GDB

2.load a core file

3.run attatched python script "inheirTest.py" through command `source inheirTest.py"

4.error occurs

Actual Result
Traceback (most recent call last):
  File "inheirTest.py", line 16, in <module>
    main()
  File "inheirTest.py", line 13, in main
    testObj = testVal(symbol.value(curFrame), "bleh")
TypeError: Value object creation takes only 1 argument

Expected Result
The object will instantiate correctly, and behave like a gdb.Value object with one additional field called 'blah.'
Comment 1 Hannes Domani 2023-12-15 21:13:18 UTC
I didn't know that subclassing of gdb.Value was even allowed, but the provided example works for me without errors since at least gdb-12.1, so I'm going to close this.