safehasattr: pass attribute name as string instead of bytes
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 02 Feb 2023 17:37:25 +0100
changeset 50610 a6a17f799839
parent 50609 90945014f4e4
child 50611 832df74a488f
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.
mercurial/templateutil.py
--- a/mercurial/templateutil.py	Thu Feb 02 17:37:11 2023 +0100
+++ b/mercurial/templateutil.py	Thu Feb 02 17:37:25 2023 +0100
@@ -281,7 +281,7 @@
 
     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))