Skip to content

Commit b4ee5db

Browse files
committed
Set __name__ for list validators in rcsetup.
This avoids having many validators all named `f`, which makes profiling a bit difficult (it appears that repeated validation of rcparams when resetting the style at the beginning of each test instance contributes quite a bit to the total test time). Instead, the list validator based on scalar validator function `validate_foo` is now `__name__`d `validate_foolist`, and the list validator based on scalar validator class `ValidateFoo` is now `__name__`d `ValidateFooList`.
1 parent 8a77cfb commit b4ee5db

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/matplotlib/rcsetup.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,13 @@ def f(s):
9595
return [scalar_validator(v) for v in s
9696
if not isinstance(v, six.string_types) or v]
9797
else:
98-
msg = "{0!r} must be of type: string or non-dictionary iterable.".format(s)
99-
raise ValueError(msg)
98+
raise ValueError("{!r} must be of type: string or non-dictionary "
99+
"iterable".format(s))
100+
# Cast `str` to keep Py2 happy despite `unicode_literals`.
101+
try:
102+
f.__name__ = str("{}list".format(scalar_validator.__name__))
103+
except AttributeError: # class instance.
104+
f.__name__ = str("{}List".format(type(scalar_validator).__name__))
100105
f.__doc__ = scalar_validator.__doc__
101106
return f
102107

0 commit comments

Comments
 (0)