Mercurial > hg
changeset 29720:041fecbb588a
i18n: use inspect.getsourcelines() to obtain lineno from func or class
Before, func must be a function object. I want to make it parse docstring
of classes, too.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 27 Jul 2016 21:53:14 +0900 |
parents | acf27be56d26 |
children | 479076db51be |
files | i18n/hggettext |
diffstat | 1 files changed, 1 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/i18n/hggettext Fri Aug 05 21:21:33 2016 +0900 +++ b/i18n/hggettext Wed Jul 27 21:53:14 2016 +0900 @@ -114,7 +114,7 @@ if func.__doc__: src = inspect.getsource(func) name = "%s.%s" % (path, func.__name__) - lineno = func.func_code.co_firstlineno + lineno = inspect.getsourcelines(func)[1] doc = func.__doc__ if rstrip: doc = doc.rstrip()