mercurial/templatefuncs.py
changeset 38243 06d11cd90516
parent 38242 12b6ee9e88f3
child 38244 688fbb758ba9
--- a/mercurial/templatefuncs.py	Wed Mar 21 01:39:44 2018 +0900
+++ b/mercurial/templatefuncs.py	Wed Mar 21 11:30:21 2018 +0900
@@ -262,12 +262,13 @@
         raise error.ParseError(_("get() expects two arguments"))
 
     dictarg = evalwrapped(context, mapping, args[0])
-    if not util.safehasattr(dictarg, 'getmember'):
+    key = evalfuncarg(context, mapping, args[1])
+    try:
+        return dictarg.getmember(context, mapping, key)
+    except error.ParseError as err:
         # i18n: "get" is a keyword
-        raise error.ParseError(_("get() expects a dict as first argument"))
-
-    key = evalfuncarg(context, mapping, args[1])
-    return dictarg.getmember(context, mapping, key)
+        hint = _("get() expects a dict as first argument")
+        raise error.ParseError(bytes(err), hint=hint)
 
 @templatefunc('if(expr, then[, else])')
 def if_(context, mapping, args):