safehasattr: pass attribute name as string instead of bytes
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 02 Feb 2023 17:21:04 +0100
changeset 50558 ef5435e7604e
parent 50557 6e749d4abf05
child 50559 48e69a056754
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/commandserver.py
--- a/mercurial/commandserver.py	Thu Feb 02 17:20:54 2023 +0100
+++ b/mercurial/commandserver.py	Thu Feb 02 17:21:04 2023 +0100
@@ -384,7 +384,7 @@
         if self.cmsg:
             hellomsg += b'message-encoding: %s\n' % self.cmsg.encoding
         hellomsg += b'pid: %d' % procutil.getpid()
-        if util.safehasattr(os, b'getpgid'):
+        if util.safehasattr(os, 'getpgid'):
             hellomsg += b'\n'
             hellomsg += b'pgid: %d' % os.getpgid(0)