Mercurial > public > mercurial-scm > hg-stable
diff contrib/check-py3-compat.py @ 32252:65cd7e705ff6
policy: eliminate ".pure." from module name only if marked as dual
So we can switch cext/pure modules to new layout one by one.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 13 Aug 2016 17:21:58 +0900 |
parents | b85fa6bf298b |
children | 9b81fb217820 |
line wrap: on
line diff
--- a/contrib/check-py3-compat.py Fri Aug 12 11:06:14 2016 +0900 +++ b/contrib/check-py3-compat.py Sat Aug 13 17:21:58 2016 +0900 @@ -14,6 +14,16 @@ import sys import traceback +# Modules that have both Python and C implementations. +_dualmodules = ( + 'base85.py', + 'bdiff.py', + 'diffhelpers.py', + 'mpatch.py', + 'osutil.py', + 'parsers.py', +) + def check_compat_py2(f): """Check Python 3 compatibility for a file with Python 2""" with open(f, 'rb') as fh: @@ -55,7 +65,9 @@ # out module paths for things not in a package can be confusing. if f.startswith(('hgext/', 'mercurial/')) and not f.endswith('__init__.py'): assert f.endswith('.py') - name = f.replace('/', '.')[:-3].replace('.pure.', '.') + name = f.replace('/', '.')[:-3] + if f.endswith(_dualmodules): + name = name.replace('.pure.', '.') try: importlib.import_module(name) except Exception as e: