safehasattr: pass attribute name as string instead of bytes
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 02 Feb 2023 17:21:14 +0100
changeset 50559 48e69a056754
parent 50558 ef5435e7604e
child 50560 9342271eef31
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:21:04 2023 +0100
+++ b/mercurial/commandserver.py	Thu Feb 02 17:21:14 2023 +0100
@@ -559,7 +559,7 @@
         self.ui = ui
         self.repo = repo
         self.address = opts[b'address']
-        if not util.safehasattr(socket, b'AF_UNIX'):
+        if not util.safehasattr(socket, 'AF_UNIX'):
             raise error.Abort(_(b'unsupported platform'))
         if not self.address:
             raise error.Abort(_(b'no socket path specified with --address'))