summaryrefslogtreecommitdiff
path: root/pyparsing.py
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@users.noreply.github.com>2018-08-21 08:39:48 -0500
committerGitHub <noreply@github.com>2018-08-21 08:39:48 -0500
commit23e0fee7e85278edb114746919ccaeffc47aebb0 (patch)
treece38dfadce928088281e914d58bafeae8218bd6e /pyparsing.py
parentf164cf1dd040ddefdb8f504e562ed2f782e083b5 (diff)
parentcab6d89801635efca99ded91e5a5e1e829f33876 (diff)
downloadpyparsing-git-23e0fee7e85278edb114746919ccaeffc47aebb0.tar.gz
Merge pull request #16 from hugovk/patch-2
Fix collections ABCs deprecation warning
Diffstat (limited to 'pyparsing.py')
-rw-r--r--pyparsing.py15
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",