# HG changeset patch # User Gregory Szorc # Date 1570394353 14400 # Node ID 0d612db7047cf147c4c70d3999a083bab8d08621 # Parent 66f2cc210a29eeac8a5d17e4b37525d71048dd3f py3: stop injecting pycompat.hasattr into modules I only found a single user of this pattern, probably because we use util.hasattr everywhere. Differential Revision: https://phab.mercurial-scm.org/D7008 diff -r 66f2cc210a29 -r 0d612db7047c mercurial/__init__.py --- a/mercurial/__init__.py Sun Oct 06 14:58:42 2019 -0400 +++ b/mercurial/__init__.py Sun Oct 06 16:39:13 2019 -0400 @@ -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. diff -r 66f2cc210a29 -r 0d612db7047c mercurial/pycompat.py --- a/mercurial/pycompat.py Sun Oct 06 14:58:42 2019 -0400 +++ b/mercurial/pycompat.py Sun Oct 06 16:39:13 2019 -0400 @@ -355,6 +355,7 @@ strurl = identity bytesurl = identity open = open + hasattr = hasattr setattr = setattr # this can't be parsed on Python 3 diff -r 66f2cc210a29 -r 0d612db7047c mercurial/statprof.py --- a/mercurial/statprof.py Sun Oct 06 14:58:42 2019 -0400 +++ b/mercurial/statprof.py Sun Oct 06 16:39:13 2019 -0400 @@ -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: