##// END OF EJS Templates
py3: remove superfluous indent from check-py3-compat.py
Yuya Nishihara -
r30095:e8aeeb28 default
parent child Browse files
Show More
@@ -56,33 +56,32 b' def check_compat_py3(f):'
56 if f.startswith(('hgext/', 'mercurial/')) and not f.endswith('__init__.py'):
56 if f.startswith(('hgext/', 'mercurial/')) and not f.endswith('__init__.py'):
57 assert f.endswith('.py')
57 assert f.endswith('.py')
58 name = f.replace('/', '.')[:-3].replace('.pure.', '.')
58 name = f.replace('/', '.')[:-3].replace('.pure.', '.')
59 if True:
59 try:
60 try:
60 importlib.import_module(name)
61 importlib.import_module(name)
61 except Exception as e:
62 except Exception as e:
62 exc_type, exc_value, tb = sys.exc_info()
63 exc_type, exc_value, tb = sys.exc_info()
63 # We walk the stack and ignore frames from our custom importer,
64 # We walk the stack and ignore frames from our custom importer,
64 # import mechanisms, and stdlib modules. This kinda/sorta
65 # import mechanisms, and stdlib modules. This kinda/sorta
65 # emulates CPython behavior in import.c while also attempting
66 # emulates CPython behavior in import.c while also attempting
66 # to pin blame on a Mercurial file.
67 # to pin blame on a Mercurial file.
67 for frame in reversed(traceback.extract_tb(tb)):
68 for frame in reversed(traceback.extract_tb(tb)):
68 if frame.name == '_call_with_frames_removed':
69 if frame.name == '_call_with_frames_removed':
69 continue
70 continue
70 if 'importlib' in frame.filename:
71 if 'importlib' in frame.filename:
71 continue
72 continue
72 if 'mercurial/__init__.py' in frame.filename:
73 if 'mercurial/__init__.py' in frame.filename:
73 continue
74 continue
74 if frame.filename.startswith(sys.prefix):
75 if frame.filename.startswith(sys.prefix):
75 continue
76 continue
76 break
77 break
78
77
79 if frame.filename:
78 if frame.filename:
80 filename = os.path.basename(frame.filename)
79 filename = os.path.basename(frame.filename)
81 print('%s: error importing: <%s> %s (error at %s:%d)' % (
80 print('%s: error importing: <%s> %s (error at %s:%d)' % (
82 f, type(e).__name__, e, filename, frame.lineno))
81 f, type(e).__name__, e, filename, frame.lineno))
83 else:
82 else:
84 print('%s: error importing module: <%s> %s (line %d)' % (
83 print('%s: error importing module: <%s> %s (line %d)' % (
85 f, type(e).__name__, e, frame.lineno))
84 f, type(e).__name__, e, frame.lineno))
86
85
87 if __name__ == '__main__':
86 if __name__ == '__main__':
88 if sys.version_info[0] == 2:
87 if sys.version_info[0] == 2:
General Comments 0
You need to be logged in to leave comments. Login now