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
This commit is contained in:
Ricky Stewart 2020-04-29 19:32:14 +00:00
parent c0ccd572ea
commit 233ffddc4d

View File

@ -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))