extension: check the command attributes using `sysstr`
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 31 Aug 2023 01:54:48 +0200
changeset 50922 0e6cea0c3113
parent 50921 538c5a48e8f4
child 50923 c642c03969ff
extension: check the command attributes using `sysstr` Since we are checking attributes, lets use the native representation instead of bytes.
mercurial/extensions.py
--- a/mercurial/extensions.py	Thu Aug 31 01:47:07 2023 +0200
+++ b/mercurial/extensions.py	Thu Aug 31 01:54:48 2023 +0200
@@ -165,7 +165,7 @@
 
 
 # attributes set by registrar.command
-_cmdfuncattrs = (b'norepo', b'optionalrepo', b'inferrepo')
+_cmdfuncattrs = ('norepo', 'optionalrepo', 'inferrepo')
 
 
 def _validatecmdtable(ui, cmdtable):
@@ -175,10 +175,10 @@
         missing = [a for a in _cmdfuncattrs if not util.safehasattr(f, a)]
         if not missing:
             continue
-        raise error.ProgrammingError(
-            b'missing attributes: %s' % b', '.join(missing),
-            hint=b"use @command decorator to register '%s'" % c,
-        )
+        msg = b'missing attributes: %s'
+        msg %= b', '.join([stringutil.forcebytestr(m) for m in missing])
+        hint = b"use @command decorator to register '%s'" % c
+        raise error.ProgrammingError(msg, hint=hint)
 
 
 def _validatetables(ui, mod):