From d4ae57d985ba8adbd010afce3ac8a9eef9bc1e40 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 11 Nov 2014 11:18:51 +0100 Subject: [PATCH 1/1] make load_module compatible with python 3.2 --- mass_build.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mass_build.py b/mass_build.py index c5f4ddd..79bc17a 100755 --- a/mass_build.py +++ b/mass_build.py @@ -20,14 +20,20 @@ import vcs, build_system import argparse, os, sys, subprocess from collections import OrderedDict -# helper funcrions +# helper functions def load_module(name, path, write_bytecode = False): - import importlib.machinery - old_val = sys.dont_write_bytecode - sys.dont_write_bytecode = not write_bytecode - module = importlib.machinery.SourceFileLoader(name, path).load_module() - sys.dont_write_bytecode = old_val - return module + old_val = sys.dont_write_bytecode + sys.dont_write_bytecode = not write_bytecode + module = None + try: + from importlib.machinery import SourceFileLoader + module = SourceFileLoader(name, path).load_module() + except ImportError: + import imp + module = imp.load_source(name, path) + finally: + sys.dont_write_bytecode = old_val + return module # an entire Project class Project: -- 2.30.2