# HG changeset patch # User Gregory Szorc <gregory.szorc@gmail.com> # Date 2014-05-10 21:54:39 # Node ID 48ef68004ec949e9da3b178a40cbaf6ab8039a48 # Parent 3de9f2c4900c58d196b74026f84e75cb619699be fix_bytes: loosen blacklist matching requirements On my Linux machine, paths seen by 2to3 include the build directory. We switch from an exact to substring match to allow 2to3 to work in more environments. diff --git a/contrib/hgfixes/fix_bytes.py b/contrib/hgfixes/fix_bytes.py --- a/contrib/hgfixes/fix_bytes.py +++ b/contrib/hgfixes/fix_bytes.py @@ -12,10 +12,10 @@ from lib2to3.pygram import python_symbol # XXX: Implementing a blacklist in 2to3 turned out to be more troublesome than # blacklisting some modules inside the fixers. So, this is what I came with. -blacklist = ['mercurial/demandimport.py', +blacklist = ('mercurial/demandimport.py', 'mercurial/py3kcompat.py', # valid python 3 already 'mercurial/i18n.py', - ] + ) def isdocstring(node): def isclassorfunction(ancestor): @@ -83,7 +83,8 @@ class FixBytes(fixer_base.BaseFix): PATTERN = 'STRING' def transform(self, node, results): - if self.filename in blacklist: + # The filename may be prefixed with a build directory. + if self.filename.endswith(blacklist): return if node.type == token.STRING: if _re.match(node.value):