* Fix exception on Python3 if nonexistent method is specified by automethod. Closes #1467

This commit is contained in:
Takayuki Shimizukawa 2014-06-09 01:43:34 +09:00
parent c8e2fd8683
commit 1d742bdcf5
3 changed files with 8 additions and 0 deletions

View File

@ -13,6 +13,7 @@ Bugs fixed
* #1457: In python3 environment, make linkcheck cause "Can't convert 'bytes'
object to str implicitly" error when link target url has a hash part.
Thanks to Jorge_C.
* #1467: Exception on Python3 if nonexistent method is specified by automethod
Release 1.2.2 (released Mar 2, 2014)
====================================

View File

@ -1183,6 +1183,8 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter):
if sys.version_info >= (3, 0):
def import_object(self):
ret = ClassLevelDocumenter.import_object(self)
if not ret:
return ret
obj_from_parent = self.parent.__dict__.get(self.object_name)
if isinstance(obj_from_parent, classmethod):
self.directivetype = 'classmethod'
@ -1196,6 +1198,8 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter):
else:
def import_object(self):
ret = ClassLevelDocumenter.import_object(self)
if not ret:
return ret
if isinstance(self.object, classmethod) or \
(isinstance(self.object, MethodType) and
self.object.im_self is not None):

View File

@ -542,6 +542,9 @@ def test_generate():
# attributes missing
assert_warns("failed to import function 'foobar' from module 'util'",
'function', 'util.foobar', more_content=None)
# method missing
assert_warns("failed to import method 'Class.foobar' from module 'test_autodoc';",
'method', 'test_autodoc.Class.foobar', more_content=None)
# test auto and given content mixing
directive.env.temp_data['py:module'] = 'test_autodoc'