Bug in ctraits.c?

Hi,

I'm new to matplotlib and very impressed by the examples (the only thing
I've tried so far). Thanks!

While trying to generate the documentation with pydoc, I've found what
looks like a bug in lib/matplotlib/enthought/traits/ctraits.c: in
traits.py, one can read:

  class CTrait ( cTrait ):

where cTrait is a type created in ctraits.c. When pydoc visits
traits.py, its finds that CTrait.__bases__ is None:

Traceback (most recent call last):
  File "/usr/bin/pydoc", line 4, in ?
    pydoc.cli()
  File "/usr/lib/python2.4/pydoc.py", line 2235, in cli
    writedocs(arg)
  File "/usr/lib/python2.4/pydoc.py", line 1497, in writedocs
    writedocs(path, pkgpath + file + '.', done)
  File "/usr/lib/python2.4/pydoc.py", line 1497, in writedocs
    writedocs(path, pkgpath + file + '.', done)
  File "/usr/lib/python2.4/pydoc.py", line 1497, in writedocs
    writedocs(path, pkgpath + file + '.', done)
  File "/usr/lib/python2.4/pydoc.py", line 1507, in writedocs
    writedoc(modname)
  File "/usr/lib/python2.4/pydoc.py", line 1483, in writedoc
    page = html.page(describe(object), html.document(object, name))
  File "/usr/lib/python2.4/pydoc.py", line 295, in document
    if inspect.ismodule(object): return self.docmodule(*args)
  File "/usr/lib/python2.4/pydoc.py", line 602, in docmodule
    for base in value.__bases__:
TypeError: iteration over non-sequence
~ %

or, with a bit more debugging information inserted in pydoc.py:

Flo-debug: key = 'StaticAnyTraitChangeNotifyWrapper'
Flo-debug: value = <class matplotlib.enthought.traits.trait_notifiers.StaticAnyTraitChangeNotifyWrapper at 0x40385b3c>
Flo-debug: value.__bases__ = ()
Flo-debug: key = 'StaticTraitChangeNotifyWrapper'
Flo-debug: value = <class matplotlib.enthought.traits.trait_notifiers.StaticTraitChangeNotifyWrapper at 0x40378a4c>
Flo-debug: value.__bases__ = ()
Flo-debug: key = 'TraitChangeNotifyWrapper'
Flo-debug: value = <class matplotlib.enthought.traits.trait_notifiers.TraitChangeNotifyWrapper at 0x403788fc>
Flo-debug: value.__bases__ = ()
wrote matplotlib.enthought.traits.trait_notifiers.html
Flo-debug: key = 'TraitArray'
Flo-debug: value = <class 'matplotlib.enthought.traits.trait_numeric.TraitArray'>
Flo-debug: value.__bases__ = (<class 'matplotlib.enthought.traits.trait_handlers.TraitHandler'>,)
wrote matplotlib.enthought.traits.trait_numeric.html
Flo-debug: key = 'CTrait'
Flo-debug: value = <class 'matplotlib.enthought.traits.traits.CTrait'>
Flo-debug: value.__bases__ = (<type 'cTrait'>,)
Flo-debug: key = 'Callable'
Flo-debug: value = <matplotlib.enthought.traits.traits.CTrait object at 0x403a2dec>
Flo-debug: value.__bases__ = None
Traceback (most recent call last):
  File "/usr/bin/pydoc", line 4, in ?
    pydoc.cli()
  File "/usr/lib/python2.4/pydoc.py", line 2239, in cli
    writedocs(arg)
  File "/usr/lib/python2.4/pydoc.py", line 1501, in writedocs
    writedocs(path, pkgpath + file + '.', done)
  File "/usr/lib/python2.4/pydoc.py", line 1501, in writedocs
    writedocs(path, pkgpath + file + '.', done)
  File "/usr/lib/python2.4/pydoc.py", line 1501, in writedocs
    writedocs(path, pkgpath + file + '.', done)
  File "/usr/lib/python2.4/pydoc.py", line 1511, in writedocs
    writedoc(modname)
  File "/usr/lib/python2.4/pydoc.py", line 1487, in writedoc
    page = html.page(describe(object), html.document(object, name))
  File "/usr/lib/python2.4/pydoc.py", line 295, in document
    if inspect.ismodule(object): return self.docmodule(*args)
  File "/usr/lib/python2.4/pydoc.py", line 606, in docmodule
    for base in value.__bases__:
TypeError: iteration over non-sequence
~ %

You can see from the preceding debug information that classes such as
TraitChangeNotifyWrapper have their __bases__ attribute set to the empty
tuple, not to None. The Python documentation also says that __bases__
should be a tuple:

  __bases__
    The tuple of base classes of a class object. If there are no base
    classes, this will be an empty tuple.

therefore the None value we get for CTrait.__bases__ seems to be a bug
in traits (probably in ctraits.c), not one in pydoc.

All this with matplotlib 0.73.1 and:

  Python 2.4.1c2 (#2, Mar 19 2005, 01:04:19)
  [GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2

Thanks,

···

--
Florent