changeset 50914:e586a7eb380a

diff-option: move attributes handling to sysstr Attributes are `str` and should be handled as such.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 31 Aug 2023 01:19:49 +0200
parents 93b0de7f13ca
children d8c8a923ee9b
files hgext/fastannotate/context.py mercurial/mdiff.py
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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__)