comparison mercurial/debugcommands.py @ 50616:2704dc40cf10

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 03 Feb 2023 02:57:49 +0100
parents 88362b8bc476
children 89556caf3c66
comparison
equal deleted inserted replaced
50615:17a86f650059 50616:2704dc40cf10
1716 1716
1717 fm = ui.formatter(b'debugformat', opts) 1717 fm = ui.formatter(b'debugformat', opts)
1718 if fm.isplain(): 1718 if fm.isplain():
1719 1719
1720 def formatvalue(value): 1720 def formatvalue(value):
1721 if util.safehasattr(value, b'startswith'): 1721 if util.safehasattr(value, 'startswith'):
1722 return value 1722 return value
1723 if value: 1723 if value:
1724 return b'yes' 1724 return b'yes'
1725 else: 1725 else:
1726 return b'no' 1726 return b'no'