Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9728144

Browse files
committed
Fix _preprocess_data for Py3.9.
On Py3.9 BoundArguments becomes a plain dict, so move_to_end doesn't exist anymore and the whole thing crashes with an AttributeError. (Travis currently fails the Py3.9 run.) As it turns out there's a simpler implementation of the whole thing anyways, one can just take whatever args/kwargs were explicitly passed in and, if "label" needs to be added, always add it to kwargs.
1 parent dc1f0d9 commit 9728144

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,24 +1399,17 @@ def inner(ax, *args, data=None, **kwargs):
13991399
if replace_names is None or k in replace_names:
14001400
bound.arguments[k] = _replacer(data, v)
14011401

1402-
bound.apply_defaults()
1403-
del bound.arguments["data"]
1402+
new_args = bound.args
1403+
new_kwargs = bound.kwargs
14041404

14051405
if needs_label:
14061406
all_kwargs = {**bound.arguments, **bound.kwargs}
14071407
# label_namer will be in all_kwargs as we asserted above that
14081408
# `label_namer is None or label_namer in arg_names`.
1409-
label = _label_from_arg(all_kwargs[label_namer], auto_label)
1410-
if "label" in arg_names:
1411-
bound.arguments["label"] = label
1412-
try:
1413-
bound.arguments.move_to_end(varkwargs_name)
1414-
except KeyError:
1415-
pass
1416-
else:
1417-
bound.arguments.setdefault(varkwargs_name, {})["label"] = label
1409+
new_kwargs["label"] = _label_from_arg(
1410+
all_kwargs[label_namer], auto_label)
14181411

1419-
return func(*bound.args, **bound.kwargs)
1412+
return func(*new_args, **new_kwargs)
14201413

14211414
inner.__doc__ = _add_data_doc(inner.__doc__, replace_names)
14221415
inner.__signature__ = new_sig

0 commit comments

Comments
 (0)