# HG changeset patch # User Pierre-Yves David # Date 2023-02-02 16:37:25 # Node ID a6a17f7998391358fbdf4621c65a21f43329c95e # Parent 90945014f4e46975b53aff5436b0ce1aec15eb21 safehasattr: pass attribute name as string instead of bytes This is a step toward replacing `util.safehasattr` usage with plain `hasattr`. The builtin function behave poorly in Python2 but this was fixed in Python3. These change are done one by one as they tend to have a small odd to trigger puzzling breackage. diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py --- a/mercurial/templateutil.py +++ b/mercurial/templateutil.py @@ -281,7 +281,7 @@ class hybrid(wrapped): def getmember(self, context, mapping, key): # TODO: maybe split hybrid list/dict types? - if not util.safehasattr(self._values, b'get'): + if not util.safehasattr(self._values, 'get'): raise error.ParseError(_(b'not a dictionary')) key = unwrapastype(context, mapping, key, self._keytype) return self._wrapvalue(key, self._values.get(key))