# HG changeset patch # User Andrew Halberstadt # Date 1566875159 0 # Node ID 983a86c020c9ac14397855a5415a751bb23d897c # Parent 8673a709d4e5e5a293717487d521a82d7b21fde4 Bug 1473498 - [mozbuild.base] Fix Python 3 incompatibilities in mozconfig error handling, r=glandium Use of 'BaseException.message` was deprecated in Python 2.6 (and removed in Python 3). We should rely on the exception's '__str__' instead. We also need to ensure the mozconfig subprocess' output is text when formatting it into the message with Py3. Differential Revision: https://phabricator.services.mozilla.com/D42843 diff --git a/python/mozbuild/mozbuild/base.py b/python/mozbuild/mozbuild/base.py --- a/python/mozbuild/mozbuild/base.py +++ b/python/mozbuild/mozbuild/base.py @@ -553,17 +553,17 @@ class MozbuildObject(ProcessExecutionMix if not notifier: raise Exception('Install notify-send (usually part of ' 'the libnotify package) to get a notification when ' 'the build finishes.') self.run_process([notifier, '--app-name=Mozilla Build System', 'Mozilla Build System', msg], ensure_exit_code=False) except Exception as e: self.log(logging.WARNING, 'notifier-failed', - {'error': e.message}, 'Notification center failed: {error}') + {'error': e}, 'Notification center failed: {error}') def _ensure_objdir_exists(self): if os.path.isdir(self.statedir): return os.makedirs(self.statedir) def _ensure_state_subdir_exists(self, subdir): @@ -823,36 +823,36 @@ class MachCommandBase(MozbuildObject): 'typically caused by having a mozconfig pointing to a ' 'different object directory from the current working ' 'directory. To solve this problem, ensure you do not have a ' 'default mozconfig in searched paths.' % (e.objdir1, e.objdir2)) sys.exit(1) except MozconfigLoadException as e: - print(e.message) + print(e) sys.exit(1) MozbuildObject.__init__(self, topsrcdir, context.settings, context.log_manager, topobjdir=topobjdir) self._mach_context = context # Incur mozconfig processing so we have unified error handling for # errors. Otherwise, the exceptions could bubble back to mach's error # handler. try: self.mozconfig except MozconfigFindException as e: - print(e.message) + print(e) sys.exit(1) except MozconfigLoadException as e: - print(e.message) + print(e) sys.exit(1) # Always keep a log of the last command, but don't do that for mach # invokations from scripts (especially not the ones done by the build # system itself). if (os.isatty(sys.stdout.fileno()) and not getattr(self, 'NO_AUTO_LOG', False)): self._ensure_state_subdir_exists('.')