This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On 21/07/16 19:37, Paul Smith wrote:
> On Thu, 2016-07-21 at 17:38 +0000, Paul_Koning@Dell.com wrote:
>>>
>>> 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().
> 
> 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 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...?
> 

Does calling the super __init__ function solve the PyLint issue?

super(self).__init__()

The old style/new style classes were introduced, I think, in Python
2.2 (I have not checked).

I'll check what we are doing in gdb.Function. But I've never linted
the Python bindings so there might be other areas where the linting
function flags usage requirements.

Cheers

Phil


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]