@@ -82,6 +82,15 @@ class names, and the use of '+', '|' and '^' operators.
82
82
except ImportError :
83
83
from threading import RLock
84
84
85
+ try :
86
+ # Python 3
87
+ from collections .abc import Iterable
88
+ from collections .abc import MutableMapping
89
+ except ImportError :
90
+ # Python 2.7
91
+ from collections import Iterable
92
+ from collections import MutableMapping
93
+
85
94
try :
86
95
from collections import OrderedDict as _OrderedDict
87
96
except ImportError :
@@ -940,7 +949,7 @@ def __getnewargs__(self):
940
949
def __dir__ (self ):
941
950
return (dir (type (self )) + list (self .keys ()))
942
951
943
- collections . MutableMapping .register (ParseResults )
952
+ MutableMapping .register (ParseResults )
944
953
945
954
def col (loc ,strg ):
946
955
"""Returns current column within a string, counting newlines as line separators.
@@ -3242,7 +3251,7 @@ def __init__( self, exprs, savelist = False ):
3242
3251
3243
3252
if isinstance ( exprs , basestring ):
3244
3253
self .exprs = [ ParserElement ._literalStringClass ( exprs ) ]
3245
- elif isinstance ( exprs , collections . Iterable ):
3254
+ elif isinstance ( exprs , Iterable ):
3246
3255
exprs = list (exprs )
3247
3256
# if sequence of strings provided, wrap with Literal
3248
3257
if all (isinstance (expr , basestring ) for expr in exprs ):
@@ -4583,7 +4592,7 @@ def oneOf( strs, caseless=False, useRegex=True ):
4583
4592
symbols = []
4584
4593
if isinstance (strs ,basestring ):
4585
4594
symbols = strs .split ()
4586
- elif isinstance (strs , collections . Iterable ):
4595
+ elif isinstance (strs , Iterable ):
4587
4596
symbols = list (strs )
4588
4597
else :
4589
4598
warnings .warn ("Invalid argument to oneOf, expected string or iterable" ,
0 commit comments