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

Skip to content

Commit 9f2b532

Browse files
committed
Call to iterable(v) is redundant - can just try and convert to a tuple directly
1 parent 0b0e311 commit 9f2b532

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/matplotlib/figure.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -785,14 +785,14 @@ def fixitems(items):
785785
# to tuples for the key
786786
ret = []
787787
for k, v in items:
788-
if iterable(v):
789-
# some objects can define __getitem__ without being
790-
# iterable and in those cases the conversion to tuples
791-
# will fail.
792-
try:
793-
v = tuple(v)
794-
except:
795-
pass
788+
# some objects can define __getitem__ without being
789+
# iterable and in those cases the conversion to tuples
790+
# will fail. So instead of using the iterable(v) function
791+
# we simply try and convert to a tuple, and proceed if not.
792+
try:
793+
v = tuple(v)
794+
except Exception:
795+
pass
796796
ret.append((k, v))
797797
return tuple(ret)
798798

0 commit comments

Comments
 (0)