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 Thu, 2016-07-21 at 19:49 +0100, Phil Muldoon wrote:
> 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).

Yes, I believe you're right.  I assume GDB doesn't try to support any
Python API older than 2.2!!

> 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.

I really must have fubar'ed my email to cause so much confusion :).

I have a set of functions in my own source directory like this:

  $ cat mystuff.py

  class MyStuff(gdb.Function):
      def __init__(self):
          super(MyStuff, self).__init__("mystuff")

      def invoke(self):
          do_stuff()

This works great, I can source these from within GDB then call
$mystuff() etc.

But when I run Pylint on "mystuff.py", I get an error because Pylint
thinks that I'm not inheriting from object.

I suspect a Pylint problem, where it can't grok that gdb.Function is a
new-style class (through the C API?), because the super() code actually
works.

Changing the above to the below works and satisfies Pylint, and for my
purposes (so far) it's equivalent, so it's not the end of the world:

  class MyStuff(gdb.Function):
      def __init__(self):
         
gdb.Function.__init__(self, "mystuff")

      def invoke(self):
          do_stuff()


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