8000 Added check to __eq__ to short-circuit out if the other object · matplotlib/matplotlib@b1f2d6a · GitHub
[go: up one dir, main page]

Skip to content

Commit b1f2d6a

Browse files
committed
Added check to __eq__ to short-circuit out if the other object
does not have the necessary attributes.
1 parent f328498 commit b1f2d6a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/matplotlib/gridspec.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,12 @@ def get_topmost_subplotspec(self):
459459
return self
460460

461461
def __eq__(self, other):
462+
# check to make sure other has the attributes
463+
# we need to do the comparison
464+
if not (hasattr(other, '_gridspec') and
465+
hasattr(other, 'num1') and
466+
hasattr(other, 'num2')):
467+
return False
462468
return all((self._gridspec == other._gridspec,
463469
self.num1 == other.num1,
464470
self.num2 == other.num2))

0 commit comments

Comments
 (0)
0