Re: Python gdb.Function is an old-style class?

Paul_Koning
2016-07-21T17:38:44Z

> On Jul 21, 2016, at 1:22 PM, Paul Smith <psmith@gnu.org> wrote:
>
> Hi all; I am writing some Python functions that subclass from
> gdb.Function, and I use super() to call the superclass __init__()
>
> It works, but pylint is failing with an error "Use of super on an old
> style class". This is usually shown when a Python2 class does not
> inherit, ultimately, from the object.
>
> Is there something magic that needs to happen to make gdb.Function
> recognized as a new-style class?

You could just call gdb.Function.__init__(self) explicitly rather than the syntactic sugar of super(). But does subclassing work at all? I had the impression that many gdb classes don't allow subclassing. Or it might not be rejected but it may not work. I haven't looked at how to make a class in C that can be subclassed; my impression is that it definitely takes work and I don't know if the necessary magic has been implemented.

For example, method calls in subclassable classes have to be via attribute lookups and Python calls, they can't be direct calls. Ditto data attribute references.

paul