py3: don't use bytes with vars() or __dict__ stable
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 05 Nov 2019 08:42:42 -0800
branchstable
changeset 43421 be384a2052aa
parent 43420 93aeebc90ff9
child 43457 92e24a139ecc
py3: don't use bytes with vars() or __dict__ Inspired by D7227. These were all the remaining instances I could find. Differential Revision: https://phab.mercurial-scm.org/D7230
contrib/perf.py
hgext/fastannotate/context.py
hgext/mq.py
mercurial/bundle2.py
mercurial/localrepo.py
mercurial/merge.py
--- a/contrib/perf.py	Tue Nov 05 12:10:38 2019 -0500
+++ b/contrib/perf.py	Tue Nov 05 08:42:42 2019 -0800
@@ -691,8 +691,8 @@
         def clearcache():
             # _tagscache has been filteredpropertycache since 2.5 (or
             # 98c867ac1330), and delattr() can't work in such case
-            if b'_tagscache' in vars(repo):
-                del repo.__dict__[b'_tagscache']
+            if '_tagscache' in vars(repo):
+                del repo.__dict__['_tagscache']
 
         return clearcache
 
--- a/hgext/fastannotate/context.py	Tue Nov 05 12:10:38 2019 -0500
+++ b/hgext/fastannotate/context.py	Tue Nov 05 08:42:42 2019 -0800
@@ -57,7 +57,7 @@
     # renamed filectx won't have a filelog yet, so set it
     # from the cache to save time
     for p in pl:
-        if not b'_filelog' in p.__dict__:
+        if not '_filelog' in p.__dict__:
             p._filelog = _getflog(f._repo, p.path())
 
     return pl
--- a/hgext/mq.py	Tue Nov 05 12:10:38 2019 -0500
+++ b/hgext/mq.py	Tue Nov 05 08:42:42 2019 -0800
@@ -567,7 +567,7 @@
         return self.seriesguards
 
     def invalidate(self):
-        for a in b'applied fullseries series seriesguards'.split():
+        for a in 'applied fullseries series seriesguards'.split():
             if a in self.__dict__:
                 delattr(self, a)
         self.applieddirty = False
--- a/mercurial/bundle2.py	Tue Nov 05 12:10:38 2019 -0500
+++ b/mercurial/bundle2.py	Tue Nov 05 08:42:42 2019 -0800
@@ -857,7 +857,7 @@
         needed to move forward to get general delta enabled.
         """
         yield self._magicstring
-        assert b'params' not in vars(self)
+        assert 'params' not in vars(self)
         paramssize = self._unpack(_fstreamparamsize)[0]
         if paramssize < 0:
             raise error.BundleValueError(
--- a/mercurial/localrepo.py	Tue Nov 05 12:10:38 2019 -0500
+++ b/mercurial/localrepo.py	Tue Nov 05 08:42:42 2019 -0800
@@ -3199,7 +3199,7 @@
         # When using the same lock to commit and strip, the phasecache is left
         # dirty after committing. Then when we strip, the repo is invalidated,
         # causing those changes to disappear.
-        if b'_phasecache' in vars(self):
+        if '_phasecache' in vars(self):
             self._phasecache.write()
 
     @unfilteredmethod
--- a/mercurial/merge.py	Tue Nov 05 12:10:38 2019 -0500
+++ b/mercurial/merge.py	Tue Nov 05 08:42:42 2019 -0800
@@ -171,7 +171,7 @@
         self._local = None
         self._other = None
         self._labels = labels
-        for var in (b'localctx', b'otherctx'):
+        for var in ('localctx', 'otherctx'):
             if var in vars(self):
                 delattr(self, var)
         if node:
@@ -196,7 +196,7 @@
         self._stateextras = {}
         self._local = None
         self._other = None
-        for var in (b'localctx', b'otherctx'):
+        for var in ('localctx', 'otherctx'):
             if var in vars(self):
                 delattr(self, var)
         self._readmergedriver = None