# HG changeset patch # User Pierre-Yves David # Date 2023-02-02 16:37:11 # Node ID 90945014f4e46975b53aff5436b0ce1aec15eb21 # Parent 046b9cce5850638b5fb1a0ffa090d7de76055bc3 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/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -346,7 +346,7 @@ def json(obj, paranoid=True): for k, v in sorted(obj.items()) ] return b'{' + b', '.join(out) + b'}' - elif util.safehasattr(obj, b'__iter__'): + elif util.safehasattr(obj, '__iter__'): out = [json(i, paranoid) for i in obj] return b'[' + b', '.join(out) + b']' raise error.ProgrammingError(b'cannot encode %r' % obj)