8000 Fix collections ABCs deprecation warning · pyparsing/pyparsing@cab6d89 · GitHub
[go: up one dir, main page]

Skip to content

Commit cab6d89

Browse files
committed
Fix collections ABCs deprecation warning
1 parent f164cf1 commit cab6d89

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pyparsing.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ class names, and the use of '+', '|' and '^' operators.
8282
except ImportError:
8383
from threading import RLock
8484

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+
8594
try:
8695
from collections import OrderedDict as _OrderedDict
8796
except ImportError:
@@ -940,7 +949,7 @@ def __getnewargs__(self):
940949
def __dir__(self):
941950
return (dir(type(self)) + list(self.keys()))
942951

943-
collections.MutableMapping.register(ParseResults)
952+
MutableMapping.register(ParseResults)
944953

945954
def col (loc,strg):
946955
"""Returns current column within a string, counting newlines as line separators.
@@ -3242,7 +3251,7 @@ def __init__( self, exprs, savelist = False ):
32423251

32433252
if isinstance( exprs, basestring ):
32443253
self.exprs = [ ParserElement._literalStringClass( exprs ) ]
3245-
elif isinstance( exprs, collections.Iterable ):
3254+
elif isinstance( exprs, Iterable ):
32463255
exprs = list(exprs)
32473256
# if sequence of strings provided, wrap with Literal
32483257
if all(isinstance(expr, basestring) for expr in exprs):
@@ -4583,7 +4592,7 @@ def oneOf( strs, caseless=False, useRegex=True ):
45834592
symbols = []
45844593
if isinstance(strs,basestring):
45854594
symbols = strs.split()
4586-
elif isinstance(strs, collections.Iterable):
4595+
elif isinstance(strs, Iterable):
45874596
symbols = list(strs)
45884597
else:
45894598
warnings.warn("Invalid argument to oneOf, expected string or iterable",

0 commit comments

Comments
 (0)
0