From 233ffddc4d7ad4687c4a6c10200056b69378a255 Mon Sep 17 00:00:00 2001 From: Ricky Stewart Date: Wed, 29 Apr 2020 19:32:14 +0000 Subject: [PATCH] Bug 1632974 - Handle case where mach Command conditions don't have a `__name__` attribute r=glandium There are `conditions` in tree that are callables but which don't have a `__name__` attribute; for example, `functools.partial` instances don't have a `__name__` since they're effectively anonymous functions. If you get to this branch and one of your `conditions` are that kind of object then you'll get a confusing error message instead of the understandable one we're trying to produce here, so account for that possibility. Differential Revision: https://phabricator.services.mozilla.com/D72957 --- python/mach/mach/registrar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/mach/mach/registrar.py b/python/mach/mach/registrar.py index 00c95d9f0b78..bc85c58a88d7 100644 --- a/python/mach/mach/registrar.py +++ b/python/mach/mach/registrar.py @@ -54,7 +54,7 @@ class MachRegistrar(object): def _condition_failed_message(cls, name, conditions): msg = ['\n'] for c in conditions: - part = [' %s' % c.__name__] + part = [' %s' % getattr(c, '__name__', c)] if c.__doc__ is not None: part.append(c.__doc__) msg.append(' - '.join(part))