[issue17446] doctest test finder doesnt find line numbers of properties
Michael Cuthbert
report at bugs.python.org
Sun Jan 31 13:51:59 EST 2016
Michael Cuthbert added the comment:
this is my first contribution to Python core so I really have no idea how to do this, but I have found a solution (works in Py3.4, 2.7):
in doctest.py after line 1087 ("lineno = getattr(obj, 'co_firstlineno', None)-1") add these lines:
if lineno is None and isinstance(obj, property) and \
obj.fget is not None:
obj = obj.fget.__code__
lineno = getattr(obj, 'co_firstlineno', None)
# no need for -1 because of decorator.
I can try to make a patch file for this, but just want to be sure I'm on the right track for contributing first. I know how to do a Git pull, but not hg/patch.
(p.s., I think the current code "lineno = getattr(obj, 'co_firstlineno', None)-1" has an error; if the getattr does not find 'co_firstlineno', it will return None and then subtract 1 from None which is a TypeError).
----------
nosy: +Michael Cuthbert
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17446>
_______________________________________
More information about the Python-bugs-list
mailing list