diff options
Diffstat (limited to 'pyparsing.py')
-rw-r--r-- | pyparsing.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/pyparsing.py b/pyparsing.py index e8aefc8..800ddd9 100644 --- a/pyparsing.py +++ b/pyparsing.py @@ -83,6 +83,15 @@ except ImportError: from threading import RLock
try:
+ # Python 3
+ from collections.abc import Iterable
+ from collections.abc import MutableMapping
+except ImportError:
+ # Python 2.7
+ from collections import Iterable
+ from collections import MutableMapping
+
+try:
from collections import OrderedDict as _OrderedDict
except ImportError:
try:
@@ -940,7 +949,7 @@ class ParseResults(object): def __dir__(self):
return (dir(type(self)) + list(self.keys()))
-collections.MutableMapping.register(ParseResults)
+MutableMapping.register(ParseResults)
def col (loc,strg):
"""Returns current column within a string, counting newlines as line separators.
@@ -3242,7 +3251,7 @@ class ParseExpression(ParserElement): if isinstance( exprs, basestring ):
self.exprs = [ ParserElement._literalStringClass( exprs ) ]
- elif isinstance( exprs, collections.Iterable ):
+ elif isinstance( exprs, Iterable ):
exprs = list(exprs)
# if sequence of strings provided, wrap with Literal
if all(isinstance(expr, basestring) for expr in exprs):
@@ -4583,7 +4592,7 @@ def oneOf( strs, caseless=False, useRegex=True ): symbols = []
if isinstance(strs,basestring):
symbols = strs.split()
- elif isinstance(strs, collections.Iterable):
+ elif isinstance(strs, Iterable):
symbols = list(strs)
else:
warnings.warn("Invalid argument to oneOf, expected string or iterable",
|