Various AttributeError crashes introspecting C module

Bug #1208337 reported by Marty
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pydoctor
Fix Released
Undecided
Unassigned

Bug Description

I was getting an AttributeError running Pydoctor on the “subvertpy” package. Version 0.5b1 failed but 0.4 was fine. I tracked the issue down and it was caused somewhere between Bazaar revision 590.1.2 “rip out . . . mess” and 590.1.5 “plan vs reality fixes” (590.1.1 was fine; 1.2-1.4 gave other errors; 1.5 gave the AttributeError)

This was the end of the traceback:

  File "/home/abs/pydoctor/pydoctor/pydoctor/astbuilder.py", line 170, in visitFrom
    names = mod.contents.keys() + mod._localNameToFullName.keys()
AttributeError: 'function' object has no attribute 'keys'

Anyway I think I fixed that one by changing that line as below. This is just a stab in the dark though; I might be completely wrong!

    names = mod.contents.keys() + _localNameToFullName.keys()

Now I get a crash further on. Here is a copy of the log. It looks like the “bases” and “baseobjects” attributes haven’t been added to the “cls” object.

There are two print() calls I added in this log just before the crash

        print(type(cls))
        print(dir(cls))

[vadmium@localhost pydoctor]$ make -C ~/proj/vcs-tools/subvertpy/ PYTHON=python2 PYDOCTOR=~/abs/pydoctor/pydoctor/bin/pydoctor pydoctor
/home/abs/pydoctor/pydoctor/bin/pydoctor --introspect-c-modules -c subvertpy.cfg --make-html
adding directory /media/disk/home/proj/vcs-tools/subvertpy/subvertpy
<module 'subvertpy.client' from '/media/disk/home/proj/vcs-tools/subvertpy/subvertpy/client.so'>
<module 'subvertpy.repos' from '/media/disk/home/proj/vcs-tools/subvertpy/subvertpy/repos.so'>
56 modules and packages discovered <module 'subvertpy._ra' from '/media/disk/home/proj/vcs-tools/subvertpy/subvertpy/_ra.so'>
116 modules and packages discovered <module 'subvertpy.wc' from '/media/disk/home/proj/vcs-tools/subvertpy/subvertpy/wc.so'>
137 modules and packages discovered/usr/lib/python2.7/site-packages/zope/interface/interface.py:548: UserWarning: Hashing uninitialized InterfaceClass instance
  warnings.warn('Hashing uninitialized InterfaceClass instance')
17/17 modules processed 2 warnings
writing html to apidocs using pydoctor.nevowhtml.writer.NevowWriter
starting ModuleIndexPage ... took 0.240938s
starting ClassIndexPage ... <class 'pydoctor.zopeinterface.ZopeInterfaceClass'>
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getstate__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_localNameToFullName', '_localNameToFullName_map', 'allImplementations', 'allImplementedInterfaces', 'allbases', 'contents', 'css_class', 'docsources', 'docstring', 'doctarget', 'documentation_location', 'expandName', 'fullName', 'implementedby_directly', 'implementsOnly', 'implements_directly', 'isVisible', 'isinterface', 'isinterfaceclass', 'isschemafield', 'kind', 'name', 'orderedcontents', 'parent', 'parentMod', 'prefix', 'privacyClass', 'rawbases', 'resolveName', 'setup', 'sourceHref', 'subclasses', 'system']
Traceback (most recent call last):
  File "/home/abs/pydoctor/pydoctor/bin/pydoctor", line 12, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/home/abs/pydoctor/pydoctor/pydoctor/driver.py", line 374, in main
    writer.writeModuleIndex(system)
  File "/home/abs/pydoctor/pydoctor/pydoctor/nevowhtml/writer.py", line 45, in writeModuleIndex
    f.write(flat.flatten(page))
  File "/usr/lib/python2.7/site-packages/nevow/flat/ten.py", line 128, in flatten
    list(iterflatten(stan, ctx, result.append))
  File "/usr/lib/python2.7/site-packages/nevow/flat/ten.py", line 79, in iterflatten
    rest = [ iter([partialflatten(ctx, stan)]) ]
  File "/usr/lib/python2.7/site-packages/nevow/flat/ten.py", line 61, in partialflatten
    return flattener(obj, context)
  File "/usr/lib/python2.7/site-packages/nevow/page.py", line 149, in _flattenElement
    synchronous[0].raiseException()
  File "<string>", line 2, in raiseException
nevow._flat.FlattenerError: Exception while flattening:
  <pydoctor.nevowhtml.summary.ClassIndexPage object at 0x3cd8150>
  ['<!DOCTYPE html\n PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n "DTD/xhtml1-strict.dtd">\n<html>\n <head>\n ', WovenContext(tag=Tag(u'title', specials={'render': directive('title')}, children=['Something'])), '\n <link href="apidocs.css" type="text/css" rel="stylesheet" />\n </head>\n <body>\n ', WovenContext(tag=Tag(u'h1', specials={'render': directive('heading')}, children=['Heading'])), '\n ', WovenContext(tag=Tag(u'ul', specials={'render': directive('stuff')}, children=['\n '])), '\n </body>\n</html>']
  File "/home/abs/pydoctor/pydoctor/pydoctor/templates/summary.html", line 11, column 4, in "ul"
  File "/usr/lib/python2.7/site-packages/nevow/_flat.py", line 415, in flatten
    element = stack[-1].next()
  File "/usr/lib/python2.7/site-packages/nevow/_flat.py", line 301, in _flatten
    result = renderFactory.renderer(rendererName)(request, root)
  File "/home/abs/pydoctor/pydoctor/pydoctor/nevowhtml/summary.py", line 87, in stuff
    for b, o in findRootClasses(self.system):
  File "/home/abs/pydoctor/pydoctor/pydoctor/nevowhtml/summary.py", line 49, in findRootClasses
    if cls.bases:
AttributeError: 'ZopeInterfaceClass' object has no attribute 'bases'

make: *** [pydoctor] Error 1
[Exit 2]
[vadmium@localhost pydoctor]$

Marty (vadmium+lp)
summary: - Various AssertionError crashes introspecting C module
+ Various AttributeError crashes introspecting C module
description: updated
description: updated
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Ah yes, all of that stuff changed recently. I'll have a look.

Changed in pydoctor:
status: New → Confirmed
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I've committed a fix, and for another problem the subvertpy docs uncovered.

Changed in pydoctor:
status: Confirmed → Won't Fix
status: Won't Fix → Fix Committed
Revision history for this message
Marty (vadmium+lp) wrote :

Great! Just confirming I did a Bazaar pull and it’s working for me as well.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Thanks for checking!

Changed in pydoctor:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.