Mercurial > hg-stable
changeset 38253:ad06a4264daf
templater: add try-except stub to runmember()
New wrapped interface will raise ParseError if the underlying object doesn't
support dict-like lookup operation.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 21 Apr 2018 17:43:16 +0900 |
parents | c2456a7726c1 |
children | 12b6ee9e88f3 |
files | mercurial/templateutil.py |
diffstat | 1 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templateutil.py Wed Mar 21 01:18:29 2018 +0900 +++ b/mercurial/templateutil.py Sat Apr 21 17:43:16 2018 +0900 @@ -666,14 +666,16 @@ if util.safehasattr(d, 'tomap'): lm = context.overlaymap(mapping, d.tomap()) return runsymbol(context, lm, memb) - if util.safehasattr(d, 'get'): - return getdictitem(d, memb) - - sym = findsymbolicname(darg) - if sym: - raise error.ParseError(_("keyword '%s' has no member") % sym) - else: - raise error.ParseError(_("%r has no member") % pycompat.bytestr(d)) + try: + if util.safehasattr(d, 'get'): + return getdictitem(d, memb) + raise error.ParseError + except error.ParseError: + sym = findsymbolicname(darg) + if sym: + raise error.ParseError(_("keyword '%s' has no member") % sym) + else: + raise error.ParseError(_("%r has no member") % pycompat.bytestr(d)) def runnegate(context, mapping, data): data = evalinteger(context, mapping, data,