comparison contrib/check-py3-compat.py @ 32280:9b81fb217820

py3: remove delayed import of importlib All supported versions of Python now have importlib. This effectively reverts b85fa6bf298b.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 13 May 2017 11:55:39 -0700
parents 65cd7e705ff6
children a9c71d578a1c
comparison
equal deleted inserted replaced
32279:68c43a416585 32280:9b81fb217820
8 # GNU General Public License version 2 or any later version. 8 # GNU General Public License version 2 or any later version.
9 9
10 from __future__ import absolute_import, print_function 10 from __future__ import absolute_import, print_function
11 11
12 import ast 12 import ast
13 import importlib
13 import os 14 import os
14 import sys 15 import sys
15 import traceback 16 import traceback
16 17
17 # Modules that have both Python and C implementations. 18 # Modules that have both Python and C implementations.
48 if haveprint and 'print_function' not in futures: 49 if haveprint and 'print_function' not in futures:
49 print('%s requires print_function' % f) 50 print('%s requires print_function' % f)
50 51
51 def check_compat_py3(f): 52 def check_compat_py3(f):
52 """Check Python 3 compatibility of a file with Python 3.""" 53 """Check Python 3 compatibility of a file with Python 3."""
53 import importlib # not available on Python 2.6
54 with open(f, 'rb') as fh: 54 with open(f, 'rb') as fh:
55 content = fh.read() 55 content = fh.read()
56 56
57 try: 57 try:
58 ast.parse(content) 58 ast.parse(content)