8000 Fix collections ABCs deprecation warning by hugovk · Pull Request #16 · pyparsing/pyparsing · GitHub
[go: up one dir, main page]

Skip to content

Fix collections ABCs deprecation warning #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions pyparsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ class names, and the use of '+', '|' and '^' operators.
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:
Expand Down Expand Up @@ -940,7 +949,7 @@ def __getnewargs__(self):
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.
Expand Down Expand Up @@ -3242,7 +3251,7 @@ def __init__( self, exprs, savelist = False ):

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):
Expand Down Expand Up @@ -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",
Expand Down
0