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

Paul Smith <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
On Thu, 2016-07-21 at 17:38 +0000, [email protected] wrote:
> > 
> > On Jul 21, 2016, at 1:22 PM, Paul Smith <[email protected]> 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().

Well, super() is not always just syntactic sugar.  It actually makes a
big difference in some class hierarchies (it solves the diamond
inheritance problem for example).  And, it avoids needing to modify
subclasses if you change the superclass hierarchy which is nice.

However, in my specific situation they are equivalent and that's
definitely the approach I'll take, if there's no other straightforward
solution.

> I just tried the example shown in the manual, and it runs without
> errors.  I don't get the error message you quoted, and the resulting
> function works correctly.

Sorry I was unclear.  The warning isn't generated by Python, and indeed
using super() appears to work fine in my code as well.

However part of our static analysis requires that all Python code added
to the codebase, including local GDB functions, pass Pylint.  It's
pylint which is complaining about this, not Python itself.

I suppose it could be a Pylint problem...?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.