Only import compiler when necessary, it's not available in 3.x.

This commit is contained in:
David Wilson 2017-09-22 13:35:24 +05:30
parent aa817f1b83
commit 8054fa867a
1 changed files with 8 additions and 7 deletions

View File

@ -1,11 +1,4 @@
try:
import ast
except ImportError:
# ast module is not available in Python 2.4.x, instead we shall use the
# the compiler module as a fallback
ast = None
import commands
import compiler
import errno
import getpass
import imp
@ -27,6 +20,14 @@ import time
import types
import zlib
try:
import ast
except ImportError:
# ast module is not available in Python 2.4.x, instead we shall use the the
# compiler module as a fallback
ast = None
import compiler
if not hasattr(pkgutil, 'find_loader'):
# find_loader() was new in >=2.5, but the modern pkgutil.py syntax has
# been kept intentionally 2.3 compatible so we can reuse it.