diff options
author | Paul McGuire <ptmcg@users.noreply.github.com> | 2020-06-27 17:46:45 -0500 |
---|---|---|
committer | Paul McGuire <ptmcg@users.noreply.github.com> | 2020-06-27 17:46:45 -0500 |
commit | 8f588705fb0795bfe80fe04dfcbc15e56a893e5c (patch) | |
tree | 8dab16d7530b07eee0057eac53765b43adbc0ecb | |
parent | d364aeaa936819ed3d8bd8629e8af61e362c0eee (diff) | |
download | pyparsing-git-8f588705fb0795bfe80fe04dfcbc15e56a893e5c.tar.gz |
Minor code cleanups, remove more Py2-compatibilty code
-rw-r--r-- | pyparsing/__init__.py | 2 | ||||
-rw-r--r-- | pyparsing/core.py | 15 |
2 files changed, 6 insertions, 11 deletions
diff --git a/pyparsing/__init__.py b/pyparsing/__init__.py index 02729f5..e896d6c 100644 --- a/pyparsing/__init__.py +++ b/pyparsing/__init__.py @@ -95,7 +95,7 @@ classes inherit from. Use the docstrings for examples of how to: """ __version__ = "3.0.0a2" -__versionTime__ = "22 June 2020 22:03 UTC" +__versionTime__ = "27 June 2020 22:45 UTC" __author__ = "Paul McGuire <ptmcg@users.sourceforge.net>" from .util import * diff --git a/pyparsing/core.py b/pyparsing/core.py index 10891d4..72de6de 100644 --- a/pyparsing/core.py +++ b/pyparsing/core.py @@ -136,7 +136,7 @@ _trim_arity_call_line = None def _trim_arity(func, maxargs=2): - "decorator to trim function calls to match the arity of the target" + """decorator to trim function calls to match the arity of the target""" global _trim_arity_call_line if func in singleArgBuiltins: @@ -190,11 +190,8 @@ def _trim_arity(func, maxargs=2): raise # copy func name to wrapper for sensible debug output - func_name = "<parse action>" - try: - func_name = getattr(func, "__name__", getattr(func, "__class__").__name__) - except Exception: - func_name = str(func) + # (can't use functools.wraps, since that messes with function signature) + func_name = getattr(func, "__name__", getattr(func, "__class__").__name__) wrapper.__name__ = func_name return wrapper @@ -247,7 +244,6 @@ def _defaultExceptionDebugAction(instring, loc, expr, exc): def nullDebugAction(*args): """'Do-nothing' debug action, to suppress debugging output during parsing.""" - pass class ParserElement(ABC): @@ -913,8 +909,8 @@ class ParserElement(ABC): if t: if isinstance(t, ParseResults): out += t.asList() - elif isinstance(t, list): - out += t + elif isinstance(t, Iterable) and not isinstance(t, str_type): + out += list(t) else: out.append(t) lastE = e @@ -1469,7 +1465,6 @@ class ParserElement(ABC): """ Child classes must define this method, which defines how the `defaultName` is set. """ - pass def setName(self, name): """ |