safehasattr: pass attribute name as string instead of bytes
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 02 Feb 2023 17:26:32 +0100
changeset 50575 029fe2f012c8
parent 50574 c04abc7340f1
child 50576 3b642b384b14
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/hg.py
--- a/mercurial/hg.py	Thu Feb 02 17:26:23 2023 +0100
+++ b/mercurial/hg.py	Thu Feb 02 17:26:32 2023 +0100
@@ -1567,7 +1567,7 @@
 
 def remoteui(src, opts):
     """build a remote ui from ui or repo and opts"""
-    if util.safehasattr(src, b'baseui'):  # looks like a repository
+    if util.safehasattr(src, 'baseui'):  # looks like a repository
         dst = src.baseui.copy()  # drop repo-specific config
         src = src.ui  # copy target options from repo
     else:  # assume it's a global ui object