templater: add try-except stub to runmember()
New wrapped interface will raise ParseError if the underlying object doesn't
support dict-like lookup operation.
--- 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,