Fix test_autodoc with Python 3.3, patches by Jon and Takayuki.

This commit is contained in:
Georg Brandl 2012-11-01 17:52:41 +01:00
parent 21d57d3125
commit 72962c99b7
2 changed files with 10 additions and 5 deletions

View File

@ -1105,7 +1105,7 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter):
"""
objtype = 'method'
member_order = 50
priority = 0
priority = 1 # must be more than FunctionDocumenter
@classmethod
def can_document_member(cls, member, membername, isattr, parent):

View File

@ -197,13 +197,18 @@ def get_module_source(modname):
except Exception, err:
raise PycodeError('error importing %r' % modname, err)
mod = sys.modules[modname]
if hasattr(mod, '__loader__'):
filename = getattr(mod, '__file__', None)
loader = getattr(mod, '__loader__', None)
if loader and getattr(loader, 'get_filename', None):
try:
source = mod.__loader__.get_source(modname)
filename = loader.get_filename(modname)
except Exception, err:
raise PycodeError('error getting filename for %r' % filename, err)
if filename is None and loader:
try:
return 'string', loader.get_source(modname)
except Exception, err:
raise PycodeError('error getting source for %r' % modname, err)
return 'string', source
filename = getattr(mod, '__file__', None)
if filename is None:
raise PycodeError('no source found for module %r' % modname)
filename = path.normpath(path.abspath(filename))