Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pydoctor throws AttributeError #11

Closed
mwhudson opened this issue Jan 12, 2015 · 7 comments
Closed

pydoctor throws AttributeError #11

mwhudson opened this issue Jan 12, 2015 · 7 comments
Labels
Confirmed This issue has been confirmed by a core pydoctor dev Medium priority

Comments

@mwhudson
Copy link
Contributor

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


Imported from Launchpad using lp2gh.

@mwhudson mwhudson added Confirmed This issue has been confirmed by a core pydoctor dev Medium priority labels Jan 12, 2015
@mwhudson
Copy link
Contributor Author

(by mwhudson)
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

@mwhudson
Copy link
Contributor Author

@mwhudson
Copy link
Contributor Author

(by allo)
what's the status of this bug?
will it be fixed anytime soon?

@mwhudson
Copy link
Contributor Author

(by mwhudson)
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!

@mwhudson
Copy link
Contributor Author

(by allo)
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
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'

@mwhudson
Copy link
Contributor Author

(by mwhudson)
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.

@mthuurne
Copy link
Contributor

Since the code changed significantly in the last 10 years, I'm going to assume this issue has been fixed at some point. Therefore I'm closing this report. I do agree that pydoctor should never crash, no matter how complex the code it's analyzing, so if something similar happens again, please open a new issue.

We're gradually adopting mypy now, so unexpected None values should become a thing of the past.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Confirmed This issue has been confirmed by a core pydoctor dev Medium priority
Projects
None yet
Development

No branches or pull requests

2 participants