Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b49cd67

Browse files
limit the AttributeError exception block to the single relevant line calling getattr
1 parent 7d2f76b commit b49cd67

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

‎lib/matplotlib/legend.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -599,25 +599,25 @@ def __init__(
599599
for getter_name in getter_names:
600600
try:
601601
color = getattr(handle, getter_name)()
602-
if isinstance(color, np.ndarray):
603-
if color.size == 0:
604-
continue
605-
elif (
606-
color.shape[0] == 1
607-
or np.isclose(color, color[0]).all()
608-
):
609-
text.set_color(color[0])
610-
else:
611-
pass
612-
elif cbook._str_lower_equal(color, 'none'):
602+
except AttributeError:
603+
continue
604+
if isinstance(color, np.ndarray):
605+
if color.size == 0:
613606
continue
614-
elif mpl.colors.to_rgba(color)[3] == 0:
615-
continue
607+
elif (
608+
color.shape[0] == 1
609+
or np.isclose(color, color[0]).all()
610+
):
611+
text.set_color(color[0])
616612
else:
617-
text.set_color(color)
618-
break
619-
except AttributeError:
613+
pass
614+
elif cbook._str_lower_equal(color, 'none'):
620615
continue
616+
elif mpl.colors.to_rgba(color)[3] == 0:
617+
continue
618+
else:
619+
text.set_color(color)
620+
break
621621
elif cbook._str_equal(labelcolor, 'none'):
622622
for text in self.texts:
623623
text.set_color(labelcolor)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /