pydoctor throws AttributeError

Bug #614605 reported by Allo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pydoctor
Confirmed
Medium
Unassigned
pydoctor (Debian)
Fix Released
Unknown

Bug Description

> pydoctor -c doc/pydoctor.cfg
/usr/lib/pymodules/python2.6/pydoctor/model.py:6: DeprecationWarning: the sets module is deprecated
  import sets
adding directory otfbot
findImportStars
74 / 74 modules parsed
extractDocstrings
74 / 74 modules parsed 13 warnings
finalStateComputations
Traceback (most recent call last):
  File "/usr/bin/pydoctor", line 5, in <module>
    main(sys.argv[1:])
  File "/usr/lib/pymodules/python2.6/pydoctor/driver.py", line 247, in main
    f()
  File "/usr/lib/pymodules/python2.6/pydoctor/astbuilder.py", line 352, in finalStateComputations
    self._finalStateComputations()
  File "/usr/lib/pymodules/python2.6/pydoctor/twisted.py", line 165, in _finalStateComputations
    super(TwistedASTBuilder, self)._finalStateComputations()
  File "/usr/lib/pymodules/python2.6/pydoctor/astbuilder.py", line 235, in _finalStateComputations
    self.recordBasesAndSubclasses()
  File "/usr/lib/pymodules/python2.6/pydoctor/astbuilder.py", line 243, in recordBasesAndSubclasses
    o.subclasses.append(cls)
AttributeError: 'Module' object has no attribute 'subclasses'

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

Is this pydoctor from current trunk?

Can you poke around using pydoctor --pdb and try to see what code is triggering the problem. I imagine it could be something like:

import name

class name: pass

class subclass(name): pass

tags: removed: attributeerror subclasses
Revision history for this message
Allo (allo) wrote :
Revision history for this message
Allo (allo) wrote :

what's the status of this bug?
will it be fixed anytime soon?

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

I understand the problem, at least to some extent.

The basic problem is that I assumed Python was more consistent than it is :-) The way names in import statements is resolved is somewhat different to how names in general are resolved, in particular when a package __init__ defines a name that collides with a module.

I'll get it fixed I guess, but it might take a while, I'm afraid. Knowing you care helps motivate me!

Changed in pydoctor:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Allo (allo) wrote :

oh, thanks for the feedback on the issue.

i tried a bit, the problem is the __init__.py in the package pluginSupport. Delete it, and it works. you see it in the linked git commit.

there seems to be a problem, that both the package and a file have the name pluginSupport. if i move pluginSupport.py to plSupport.py, i get an error in the html-generation, not in the subclasses place.

another thing i tried (without understand much of your code) is "if o:" -> 'if o and hasattr(o, "subclasses"):'. this also moves the exception to another place.

the error with plSupport.py instead of pluginSupport.py:

writing html to doc/api/ using pydoctor.html.SystemWriter
Traceback (most recent call last):
  File "/usr/bin/pydoctor", line 5, in <module>
    main(sys.argv[1:])
  File "/usr/lib/pymodules/python2.6/pydoctor/driver.py", line 287, in main
    writer.writeIndividualFiles(subjects, options.htmlfunctionpages)
  File "/usr/lib/pymodules/python2.6/pydoctor/html.py", line 185, in writeIndividualFiles
    self.writeIndividualFiles(sub.orderedcontents, functionpages)
  File "/usr/lib/pymodules/python2.6/pydoctor/html.py", line 185, in writeIndividualFiles
    self.writeIndividualFiles(sub.orderedcontents, functionpages)
  File "/usr/lib/pymodules/python2.6/pydoctor/html.py", line 185, in writeIndividualFiles
    self.writeIndividualFiles(sub.orderedcontents, functionpages)
  File "/usr/lib/pymodules/python2.6/pydoctor/html.py", line 185, in writeIndividualFiles
    self.writeIndividualFiles(sub.orderedcontents, functionpages)
  File "/usr/lib/pymodules/python2.6/pydoctor/html.py", line 185, in writeIndividualFiles
    self.writeIndividualFiles(sub.orderedcontents, functionpages)
  File "/usr/lib/pymodules/python2.6/pydoctor/html.py", line 181, in writeIndividualFiles
    html = self.getHTMLFor(sub)
  File "/usr/lib/pymodules/python2.6/pydoctor/html.py", line 194, in getHTMLFor
    d = fun(o)
  File "/usr/lib/pymodules/python2.6/pydoctor/html.py", line 316, in html_TwistedClass
    x += self._genChildren(cls.orderedcontents, link=link_)
  File "/usr/lib/pymodules/python2.6/pydoctor/html.py", line 370, in _genChildren
    'doc': summaryDoc(obj)}
  File "/usr/lib/pymodules/python2.6/pydoctor/html.py", line 30, in summaryDoc
    return doc2html(obj, doc)
  File "/usr/lib/pymodules/python2.6/pydoctor/html.py", line 53, in g
    r = _cache[args] = f(*args)
  File "/usr/lib/pymodules/python2.6/pydoctor/html.py", line 84, in doc2html
    crap = pdoc.to_html(_EpydocLinker(obj))
AttributeError: 'NoneType' object has no attribute 'to_html'

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

The branch I've just linked to the report contains a failing test case which is the crux of the issue I think.

It's also a bug that pydoctor blows up in the way it does, if it misinterprets what's going on that's one thing, but it shouldn't blow up like this.

I'm not sure what the real fix for this is. It probably is the thing I mentioned first -- the lookup path for import statements and python expressions are not quite the same. That might be quite a large change though, and it might be possible to bodge it more simply. Not sure if that would be a good idea though.

Changed in pydoctor (Debian):
status: Unknown → Confirmed
Revision history for this message
Magosányi Árpád (mag-magwas) wrote :

I have a similar-sounding issue.
Triggered by commit 89428d07347d67e287d8f605979739f6ff61ad9e and worked around in acd774d5a2640f1e24359870df988894d7acf88b of https://github.com/magwas/PDOauth
The workaround is not to use wildcard import:

diff --git a/src/pdoauth/main.py b/src/pdoauth/main.py
index 6c65cd6..1653ecb 100644
--- a/src/pdoauth/main.py
+++ b/src/pdoauth/main.py
@@ -17,7 +17,7 @@ from pdoauth.forms.CredentialForm import CredentialForm
 from pdoauth.forms.CredentialIdentifierForm import CredentialIdentifierForm
 from pdoauth.forms.DeregisterDoitForm import DeregisterDoitForm
 from pdoauth.FlaskInterface import FlaskInterface
-from pdoauth.models import * # @UnusedWildImport
+from pdoauth import models # @UnusedWildImport

 db.create_all()

Changed in pydoctor (Debian):
status: Confirmed → 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.