D7008: py3: stop injecting pycompat.hasattr into modules

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Mon Oct 7 10:38:16 EDT 2019


Closed by commit rHG0d612db7047c: py3: stop injecting pycompat.hasattr into modules (authored by indygreg).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7008?vs=16923&id=16931

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7008/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7008

AFFECTED FILES
  mercurial/__init__.py
  mercurial/pycompat.py
  mercurial/statprof.py

CHANGE DETAILS

diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -168,7 +168,7 @@
         # a float
         if frequency:
             self.sample_interval = 1.0 / frequency
-        elif not hasattr(self, 'sample_interval'):
+        elif not pycompat.hasattr(self, 'sample_interval'):
             # default to 1000 Hz
             self.sample_interval = 1.0 / 1000.0
         else:
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -355,6 +355,7 @@
     strurl = identity
     bytesurl = identity
     open = open
+    hasattr = hasattr
     setattr = setattr
 
     # this can't be parsed on Python 3
diff --git a/mercurial/__init__.py b/mercurial/__init__.py
--- a/mercurial/__init__.py
+++ b/mercurial/__init__.py
@@ -171,7 +171,7 @@
                 r, c = t.start
                 l = (
                     b'; from mercurial.pycompat import '
-                    b'delattr, getattr, hasattr\n'
+                    b'delattr, getattr\n'
                 )
                 for u in tokenize.tokenize(io.BytesIO(l).readline):
                     if u.type in (tokenize.ENCODING, token.ENDMARKER):
@@ -220,7 +220,7 @@
     # ``replacetoken`` or any mechanism that changes semantics of module
     # loading is changed. Otherwise cached bytecode may get loaded without
     # the new transformation mechanisms applied.
-    BYTECODEHEADER = b'HG\x00\x0f'
+    BYTECODEHEADER = b'HG\x00\x10'
 
     class hgloader(importlib.machinery.SourceFileLoader):
         """Custom module loader that transforms source code.



To: indygreg, #hg-reviewers
Cc: durin42, martinvonz, mercurial-devel


More information about the Mercurial-devel mailing list