# HG changeset patch # User FUJIWARA Katsunori # Date 1470677314 -32400 # Node ID 8faac092bb0cfcbd36db68b2bafa66401d5a8b8b # Parent 297a0dc503208b42efa928bf6f2287aa141d9fe4 py3: make check-py3-compat.py use correct module name at loading pure modules Before this patch, check-py3-compat.py implies unintentional ".pure" sub-package name at loading pure modules, because module name is composed by just replacing "/" in the path to actual ".py" file by ".". This makes pure modules belong to "mercurial.pure" package, and prevents them from importing a module belonging to "mercurial" package relatively by "from . import foo" or so. This is reason why pure modules fail to import another module relatively only at examination by check-py3-compat.py. diff -r 297a0dc50320 -r 8faac092bb0c contrib/check-py3-compat.py --- a/contrib/check-py3-compat.py Tue Aug 09 02:28:34 2016 +0900 +++ b/contrib/check-py3-compat.py Tue Aug 09 02:28:34 2016 +0900 @@ -55,7 +55,7 @@ # 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] + name = f.replace('/', '.')[:-3].replace('.pure.', '.') with open(f, 'r') as fh: try: imp.load_module(name, fh, '', ('py', 'r', imp.PY_SOURCE)) diff -r 297a0dc50320 -r 8faac092bb0c tests/test-check-py3-compat.t --- a/tests/test-check-py3-compat.t Tue Aug 09 02:28:34 2016 +0900 +++ b/tests/test-check-py3-compat.t Tue Aug 09 02:28:34 2016 +0900 @@ -136,9 +136,8 @@ mercurial/patch.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) mercurial/pathutil.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) mercurial/peer.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) - mercurial/pure/mpatch.py: error importing module: cannot import name 'policy' (line *) (glob) - mercurial/pure/osutil.py: error importing module: cannot import name 'policy' (line *) (glob) - mercurial/pure/parsers.py: error importing module: No module named 'mercurial.pure.node' (line *) (glob) + mercurial/pure/mpatch.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) + mercurial/pure/parsers.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) mercurial/pushkey.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) mercurial/pvec.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) mercurial/registrar.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob)