py3: make check-py3-compat.py import importlib only if necessary
authorYuya Nishihara <yuya@tcha.org>
Sun, 09 Oct 2016 17:02:34 +0200
changeset 30117 b85fa6bf298b
parent 30116 1c01fa29630f
child 30118 c19266edd93e
py3: make check-py3-compat.py import importlib only if necessary importlib isn't available on Python 2.6, and it isn't necessary for Py2 checks.
contrib/check-py3-compat.py
--- a/contrib/check-py3-compat.py	Sun Oct 09 08:09:20 2016 -0700
+++ b/contrib/check-py3-compat.py	Sun Oct 09 17:02:34 2016 +0200
@@ -10,7 +10,6 @@
 from __future__ import absolute_import, print_function
 
 import ast
-import importlib
 import os
 import sys
 import traceback
@@ -41,6 +40,7 @@
 
 def check_compat_py3(f):
     """Check Python 3 compatibility of a file with Python 3."""
+    import importlib  # not available on Python 2.6
     with open(f, 'rb') as fh:
         content = fh.read()