Skip to content

Commit d0d5b6a

Browse files
committed
For Python 2.7 compatibility.
1 parent 83dbef7 commit d0d5b6a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

folium/utilities.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
import copy
1313
import uuid
1414
import collections
15+
try:
16+
from collections import abc
17+
except ImportError:
18+
import collections as abc
1519

1620
import numpy as np
1721

@@ -23,9 +27,14 @@
2327
_VALID_URLS.discard('')
2428

2529

30+
def _is_sized_iterable(arg):
31+
"""Validates the arg is Sized & Iterable"""
32+
return isinstance(arg, abc.Sized) & isinstance(arg, abc.Iterable)
33+
34+
2635
def _validate_location(location):
2736
"""Validates and formats location values before setting."""
28-
if not isinstance(location, collections.abc.Collection):
37+
if not _is_sized_iterable(location):
2938
raise TypeError('Expected a collection object for location, got '
3039
'{!r}'.format(location))
3140
if len(location) != 2:
@@ -58,7 +67,7 @@ def _iter_tolist(x):
5867

5968
def _flatten(container):
6069
for i in container:
61-
if isinstance(i, collections.abc.Collection):
70+
if _is_sized_iterable(i):
6271
for j in _flatten(i):
6372
yield j
6473
else:

0 commit comments

Comments
 (0)