[Python-projects] __init__ method from a non direct base class <logilab.astng.Yes object at 0xb7f8392c> is called

skip at pobox.com skip at pobox.com
Mon Nov 20 18:18:57 CET 2006


    >> I found a email to this list in august from Skip Montano reporting
    >> the problem. Give that pylint is unusable with this bug in place I'm
    >> surprised that the lastest released kit contains this show stopper
    >> bug.

    Alexandre> If you read the recent archives you will see that this has
    Alexandre> been discussed, and it looks like it is a pygtk issue.

My problem seems to be related to our use of the pygtk module to extend
sys.path to refer to the relevant version of gtk.  For example, our code
contains:

    import pygtk
    pygtk.require("2.6")

    import gobject

The pygtk.require() call adds our gtk 2.6 installation directory to
sys.path.  When I run pylint over a trivial script that subclasses
gobject.GObject:

    import pygtk
    pygtk.require("2.6")

    import gobject

    class GObjectSubclass(gobject.GObject):
        def __init__(self):
            gobject.GObject.__init__(self)
            self.time = 0.0

        def get_time(self):
            return self.time

        def set_time(self, t):
            self.time = t

I get this error:

    chron.py:8: [W, GObjectSubclass.__init__] __init__ method from a non
    direct base class <logilab.astng.Yes object at 0x8252eec> is called

If, however, I set PYTHONPATH at the shell level before running pylint, that
error disappears.  I assume pylint uses PYTHONPATH to locate the gobject
module and rummage around in it.  There is no gobject module in the default
sys.path in our environment.  I'm not sure how pylint could improve in this
regard without actually importing the module/script.

In any case, gtk-related module names are correct in our environment (Gtk
2.6):

    >>> gobject.GObject.__module__
    'gobject'
    >>> import gtk
    >>> gtk.Button.__module__
    'gtk'

Skip


More information about the Python-Projects mailing list