# HG changeset patch # User Pierre-Yves David # Date 1675354983 -3600 # Node ID 1ea84989c3898e5e89fc9737e6bc6da58d366a85 # Parent 8020be6a9d282b2770e0dd8684628305daf73c7e 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 -r 8020be6a9d28 -r 1ea84989c389 mercurial/debugcommands.py --- a/mercurial/debugcommands.py Thu Feb 02 17:22:55 2023 +0100 +++ b/mercurial/debugcommands.py Thu Feb 02 17:23:03 2023 +0100 @@ -1943,7 +1943,7 @@ """show stats related to the changelog index""" repo.changelog.shortest(repo.nullid, 1) index = repo.changelog.index - if not util.safehasattr(index, b'stats'): + if not util.safehasattr(index, 'stats'): raise error.Abort(_(b'debugindexstats only works with native code')) for k, v in sorted(index.stats().items()): ui.write(b'%s: %d\n' % (k, v))