From 8054fa867ac7fb5e80fe75c181b297f21618feac Mon Sep 17 00:00:00 2001 From: David Wilson Date: Fri, 22 Sep 2017 13:35:24 +0530 Subject: [PATCH] Only import compiler when necessary, it's not available in 3.x. --- mitogen/master.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mitogen/master.py b/mitogen/master.py index 288de77f..7b7c0ff1 100644 --- a/mitogen/master.py +++ b/mitogen/master.py @@ -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.