diff options
author | Hugo <hugovk@users.noreply.github.com> | 2018-08-09 16:38:02 +0300 |
---|---|---|
committer | Hugo <hugovk@users.noreply.github.com> | 2018-08-21 16:12:06 +0300 |
commit | cab6d89801635efca99ded91e5a5e1e829f33876 (patch) | |
tree | ce38dfadce928088281e914d58bafeae8218bd6e /pyparsing.py | |
parent | f164cf1dd040ddefdb8f504e562ed2f782e083b5 (diff) | |
download | pyparsing-git-cab6d89801635efca99ded91e5a5e1e829f33876.tar.gz |
Fix collections ABCs deprecation warning
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",
|