diff-option: move attributes handling to sysstr
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 31 Aug 2023 01:19:49 +0200
changeset 50914 e586a7eb380a
parent 50913 93b0de7f13ca
child 50915 d8c8a923ee9b
diff-option: move attributes handling to sysstr Attributes are `str` and should be handled as such.
hgext/fastannotate/context.py
mercurial/mdiff.py
--- a/hgext/fastannotate/context.py	Fri Sep 01 12:11:11 2023 +0200
+++ b/hgext/fastannotate/context.py	Thu Aug 31 01:19:49 2023 +0200
@@ -151,7 +151,10 @@
 
 def hashdiffopts(diffopts):
     diffoptstr = stringutil.pprint(
-        sorted((k, getattr(diffopts, k)) for k in mdiff.diffopts.defaults)
+        sorted(
+            (k, getattr(diffopts, pycompat.sysstr(k)))
+            for k in mdiff.diffopts.defaults
+        )
     )
     return hex(hashutil.sha1(diffoptstr).digest())[:6]
 
--- a/mercurial/mdiff.py	Fri Sep 01 12:11:11 2023 +0200
+++ b/mercurial/mdiff.py	Thu Aug 31 01:19:49 2023 +0200
@@ -78,7 +78,7 @@
             v = opts.get(k)
             if v is None:
                 v = self.defaults[k]
-            setattr(self, k, v)
+            setattr(self, pycompat.sysstr(k), v)
 
         try:
             self.context = int(self.context)
@@ -89,14 +89,15 @@
             )
 
     def copy(self, **kwargs):
-        opts = {k: getattr(self, k) for k in self.defaults}
+        opts = {k: getattr(self, pycompat.sysstr(k)) for k in self.defaults}
         opts = pycompat.strkwargs(opts)
         opts.update(kwargs)
         return diffopts(**opts)
 
     def __bytes__(self):
         return b", ".join(
-            b"%s: %r" % (k, getattr(self, k)) for k in self.defaults
+            b"%s: %r" % (k, getattr(self, pycompat.sysstr(k)))
+            for k in self.defaults
         )
 
     __str__ = encoding.strmethod(__bytes__)