[PATCH 3 of 3] py3: remove superfluous indent from check-py3-compat.py

Yuya Nishihara yuya at tcha.org
Sun Oct 9 03:17:57 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1475940160 -7200
#      Sat Oct 08 17:22:40 2016 +0200
# Node ID e6f44ecf2b4afc13f583b0431a25d8e44dd6b09f
# Parent  fbd4b7cbb2930550f164f1fef3c3a8a64011a4c8
py3: remove superfluous indent from check-py3-compat.py

diff --git a/contrib/check-py3-compat.py b/contrib/check-py3-compat.py
--- a/contrib/check-py3-compat.py
+++ b/contrib/check-py3-compat.py
@@ -56,33 +56,32 @@ def check_compat_py3(f):
     if f.startswith(('hgext/', 'mercurial/')) and not f.endswith('__init__.py'):
         assert f.endswith('.py')
         name = f.replace('/', '.')[:-3].replace('.pure.', '.')
-        if True:
-            try:
-                importlib.import_module(name)
-            except Exception as e:
-                exc_type, exc_value, tb = sys.exc_info()
-                # We walk the stack and ignore frames from our custom importer,
-                # import mechanisms, and stdlib modules. This kinda/sorta
-                # emulates CPython behavior in import.c while also attempting
-                # to pin blame on a Mercurial file.
-                for frame in reversed(traceback.extract_tb(tb)):
-                    if frame.name == '_call_with_frames_removed':
-                        continue
-                    if 'importlib' in frame.filename:
-                        continue
-                    if 'mercurial/__init__.py' in frame.filename:
-                        continue
-                    if frame.filename.startswith(sys.prefix):
-                        continue
-                    break
+        try:
+            importlib.import_module(name)
+        except Exception as e:
+            exc_type, exc_value, tb = sys.exc_info()
+            # We walk the stack and ignore frames from our custom importer,
+            # import mechanisms, and stdlib modules. This kinda/sorta
+            # emulates CPython behavior in import.c while also attempting
+            # to pin blame on a Mercurial file.
+            for frame in reversed(traceback.extract_tb(tb)):
+                if frame.name == '_call_with_frames_removed':
+                    continue
+                if 'importlib' in frame.filename:
+                    continue
+                if 'mercurial/__init__.py' in frame.filename:
+                    continue
+                if frame.filename.startswith(sys.prefix):
+                    continue
+                break
 
-                if frame.filename:
-                    filename = os.path.basename(frame.filename)
-                    print('%s: error importing: <%s> %s (error at %s:%d)' % (
-                          f, type(e).__name__, e, filename, frame.lineno))
-                else:
-                    print('%s: error importing module: <%s> %s (line %d)' % (
-                          f, type(e).__name__, e, frame.lineno))
+            if frame.filename:
+                filename = os.path.basename(frame.filename)
+                print('%s: error importing: <%s> %s (error at %s:%d)' % (
+                      f, type(e).__name__, e, filename, frame.lineno))
+            else:
+                print('%s: error importing module: <%s> %s (line %d)' % (
+                      f, type(e).__name__, e, frame.lineno))
 
 if __name__ == '__main__':
     if sys.version_info[0] == 2:


More information about the Mercurial-devel mailing list