Closed Bug 1585385 Opened 10 months ago Closed 9 months ago

pre-commit link hook in .hgrc causes "ImportError: cannot import name get_context"


(Firefox Build System :: General, defect)

Not set


(firefox71 fixed)

Tracking Status
firefox71 --- fixed


(Reporter: mjf, Assigned: ahal)


(Blocks 1 open bug, Regression)


(Keywords: in-triage)


(1 file)

MJF-MacBookPro:moz-central mfroman$ hg commit -m "will delete"
Error running mach:

['lint', '--quiet', '--workdir=staged']

The error occurred in mach itself. This is likely a bug in mach itself or a
fundamental problem with a loaded module.

You can invoke |./mach busted| to check if this issue is already on file. If it
isn't, please use |./mach busted file| to report it. If |./mach busted| is
misbehaving, you can also inspect the dependencies of bug 1543241.

If filing a bug, please include the full output of mach, including this error

The details of the failure are as follows:

ImportError: cannot import name get_context

File "/Users/mfroman/mozilla/moz-central/python/mach/mach/", line 360, in run
return self._run(argv)
File "/Users/mfroman/mozilla/moz-central/python/mach/mach/", line 417, in _run
args = parser.parse_args(argv)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1701, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1733, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1921, in _parse_known_args
positionals_end_index = consume_positionals(start_index)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1898, in consume_positionals
take_action(action, args)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1807, in take_action
action(self, namespace, argument_values, option_string)
File "/Users/mfroman/mozilla/moz-central/python/mach/mach/", line 179, in call
if handler.parser:
File "/Users/mfroman/mozilla/moz-central/python/mach/mach/", line 82, in parser
self._parser = self._parser()
File "/Users/mfroman/mozilla/moz-central/tools/lint/", line 34, in setup_argument_parser
from mozlint import cli
File "/Users/mfroman/mozilla/moz-central/build/", line 406, in call
module = self._original_import(name, globals, locals, fromlist, level)
File "/Users/mfroman/mozilla/moz-central/python/mozlint/mozlint/", line 6, in <module>
from .roller import LintRoller
File "/Users/mfroman/mozilla/moz-central/build/", line 406, in call
module = self._original_import(name, globals, locals, fromlist, level)
File "/Users/mfroman/mozilla/moz-central/python/mozlint/mozlint/", line 17, in <module>
from multiprocessing import cpu_count, get_context

As a workaround, I can remove the following lines from my .hgrc file:
pretxncommit.lint = python:tools/lint/

:ahal, any input on what might be happening here? The stack here seems to end in mozlint although it's called from an hg hook.

Flags: needinfo?(ahal)

Sorry, bug 1580280 dropped support for Python 2 in |mach lint| and I forgot to update the hook.

Assignee: nobody → ahal
Flags: needinfo?(ahal)
Regressed by: 1580280
Pushed by
[lint] Make sure hooks run |mach lint| with Python 3, r=mars
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71
You need to log in before you can comment on or make changes to this bug.