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

Skip to content

Commit 2941847

Browse files
committed
Error out in case of alias inheritance.
1 parent 52c6c77 commit 2941847

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
@@ -2783,12 +2783,13 @@ class so far, an alias named ``get_alias`` will be defined; the same will
27832783
exception will be raised.
27842784
27852785
The alias map is stored as the ``_alias_map`` attribute on the class and
2786-
can be used by `~.normalize_kwargs`.
2786+
can be used by `~.normalize_kwargs` (which assumes that higher priority
2787+
aliases come last).
27872788
"""
27882789
if cls is None:
27892790
return functools.partial(_define_aliases, alias_d)
27902791

2791-
def make_alias(name): # Enfore a closure over *name*.
2792+
def make_alias(name): # Enforce a closure over *name*.
27922793
def method(self, *args, **kwargs):
27932794
return getattr(self, name)(*args, **kwargs)
27942795
return method
@@ -2804,7 +2805,11 @@ def method(self, *args, **kwargs):
28042805
method.__doc__ = "alias for `{}`".format(prefix + prop)
28052806
setattr(cls, prefix + alias, method)
28062807
if not exists:
2807-
raise ValueError("property {} does not exist".format(prop))
2808+
raise ValueError(
2809+
"Neither getter nor setter exists for {!r}".format(prop))
28082810

2811+
if hasattr(cls, "_alias_map"):
2812+
# Need to decide on conflict resolution policy.
2813+
raise NotImplementedError("Parent class already defines aliases")
28092814
cls._alias_map = alias_d
28102815
return cls

0 commit comments

Comments
 (0)