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

Skip to content

Commit fb67c60

Browse files
committed
Error out in case of alias inheritance.
1 parent 42ea0cb commit fb67c60

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2819,12 +2819,13 @@ class so far, an alias named ``get_alias`` will be defined; the same will
28192819
exception will be raised.
28202820
28212821
The alias map is stored as the ``_alias_map`` attribute on the class and
2822-
can be used by `~.normalize_kwargs`.
2822+
can be used by `~.normalize_kwargs` (which assumes that higher priority
2823+
aliases come last).
28232824
"""
28242825
if cls is None:
28252826
return functools.partial(_define_aliases, alias_d)
28262827

2827-
def make_alias(name): # Enfore a closure over *name*.
2828+
def make_alias(name): # Enforce a closure over *name*.
28282829
def method(self, *args, **kwargs):
28292830
return getattr(self, name)(*args, **kwargs)
28302831
return method
@@ -2840,7 +2841,11 @@ def method(self, *args, **kwargs):
28402841
method.__doc__ = "alias for `{}`".format(prefix + prop)
28412842
setattr(cls, prefix + alias, method)
28422843
if not exists:
2843-
raise ValueError("property {} does not exist".format(prop))
2844+
raise ValueError(
2845+
"Neither getter nor setter exists for {!r}".format(prop))
28442846

2847+
if hasattr(cls, "_alias_map"):
2848+
# Need to decide on conflict resolution policy.
2849+
raise NotImplementedError("Parent class already defines aliases")
28452850
cls._alias_map = alias_d
28462851
return cls

0 commit comments

Comments
 (0)