diff options
author | ptmcg <ptmcg@austin.rr.com> | 2020-07-19 17:55:40 -0500 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2020-07-19 17:55:40 -0500 |
commit | de7c442afb95cff6120a26a4b2c1a43bd84cecbf (patch) | |
tree | a3fd47198cf1c38f152b7a7e68cabc01dfae6db7 | |
parent | 11cdffe3dff0449d7f49c90aaefb572c01ddb580 (diff) | |
download | pyparsing-git-de7c442afb95cff6120a26a4b2c1a43bd84cecbf.tar.gz |
Nicer default name for QuotedStrings; clean out more Py2 vestigial code
-rw-r--r-- | pyparsing/__init__.py | 2 | ||||
-rw-r--r-- | pyparsing/core.py | 13 |
2 files changed, 6 insertions, 9 deletions
diff --git a/pyparsing/__init__.py b/pyparsing/__init__.py index a66b1d5..c2d0ffb 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.0b1" -__versionTime__ = "9 July 2020 02:13 UTC" +__versionTime__ = "19 July 2020 22:54 UTC" __author__ = "Paul McGuire <ptmcg@users.sourceforge.net>" from .util import * diff --git a/pyparsing/core.py b/pyparsing/core.py index 2c08bd9..108b1d8 100644 --- a/pyparsing/core.py +++ b/pyparsing/core.py @@ -2623,6 +2623,9 @@ class QuotedString(Token): self.mayReturnEmpty = True def _generateDefaultName(self): + if self.quoteChar == self.endQuoteChar and isinstance(self.quoteChar, str_type): + return "string enclosed in {!r}".format(self.quoteChar) + return "quoted string, starting with {} ending with {}".format( self.quoteChar, self.endQuoteChar ) @@ -4617,10 +4620,7 @@ def traceParseAction(f): sys.stderr.write("<<leaving {} (ret: {!r})\n".format(thisFunc, ret)) return ret - try: - z.__name__ = f.__name__ - except AttributeError: - pass + z.__name__ = f.__name__ return z @@ -4729,10 +4729,7 @@ def tokenMap(func, *args): def pa(s, l, t): return [func(tokn, *args) for tokn in t] - try: - func_name = getattr(func, "__name__", getattr(func, "__class__").__name__) - except Exception: - func_name = str(func) + func_name = getattr(func, "__name__", getattr(func, "__class__").__name__) pa.__name__ = func_name return pa |