diff options
author | ptmcg <ptmcg@austin.rr.com> | 2020-04-10 16:52:46 -0500 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2020-04-10 16:52:46 -0500 |
commit | 486b1fd2ef7e98966665f915bc59856996ffb5b0 (patch) | |
tree | 1ac012ef3e6fc535a69304d936facbbdb7baad5e | |
parent | 72f2c5a67b4a26f584104b9ff63e1f272f54c5df (diff) | |
download | pyparsing-git-486b1fd2ef7e98966665f915bc59856996ffb5b0.tar.gz |
Fixed bug in ParseResults repr() which showed all matching entries for a results name, even if listAllMatches was set to False (Issue #205)
-rw-r--r-- | CHANGES | 8 | ||||
-rw-r--r-- | pyparsing/__init__.py | 2 | ||||
-rw-r--r-- | pyparsing/core.py | 4 | ||||
-rw-r--r-- | pyparsing/results.py | 2 | ||||
-rw-r--r-- | tests/test_unit.py | 27 |
5 files changed, 37 insertions, 6 deletions
@@ -2,6 +2,14 @@ Change Log ========== +Version 3.0.0a2 +--------------- +- Fixed bug in ParseResults repr() which showed all matching + entries for a results name, even if listAllMatches was set + to False when creating the ParseResults originally. Reported + by Nicholas42 on GitHub, good catch! (Issue #205) + + Version 3.0.0a1 - April, 2020 ----------------------------- - Removed Py2.x support and other deprecated features. Pyparsing diff --git a/pyparsing/__init__.py b/pyparsing/__init__.py index f369d6b..53550c5 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__ = "07 Apr 2020 20:23 UTC" +__versionTime__ = "10 Apr 2020 21:46 UTC" __author__ = "Paul McGuire <ptmcg@users.sourceforge.net>" from pyparsing.util import * diff --git a/pyparsing/core.py b/pyparsing/core.py index 5c68f1a..3a0dfd6 100644 --- a/pyparsing/core.py +++ b/pyparsing/core.py @@ -53,10 +53,6 @@ str_type = (str, bytes) # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__version__ = "3.0.0a1" -__versionTime__ = "3 Apr 2020 22:54 UTC" -__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>" - class __compat__(__config_flags): """ diff --git a/pyparsing/results.py b/pyparsing/results.py index 2ed4f9b..cdad8aa 100644 --- a/pyparsing/results.py +++ b/pyparsing/results.py @@ -391,7 +391,7 @@ class ParseResults: return other + self def __repr__(self): - return "(%s, %s)" % (repr(self._toklist), repr(self._tokdict)) + return "(%s, %s)" % (repr(self._toklist), self.asDict()) def __str__(self): return ( diff --git a/tests/test_unit.py b/tests/test_unit.py index de06ddf..9f27375 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -7073,6 +7073,33 @@ class Test2_WithoutPackrat(ppt.TestParseResultsAsserts, TestCase): "multiplied(3) failure with setResultsName", ) + def testParseResultsReprWithResultsNames(self): + word = pp.Word(pp.printables)("word") + res = word[...].parseString("test blub") + + print(repr(res)) + print(res["word"]) + print(res.asDict()) + + self.assertEqual( + "(['test', 'blub'], {'word': 'blub'})", + repr(res), + "incorrect repr for ParseResults with listAllMatches=False", + ) + + word = pp.Word(pp.printables)("word*") + res = word[...].parseString("test blub") + + print(repr(res)) + print(res["word"]) + print(res.asDict()) + + self.assertEqual( + "(['test', 'blub'], {'word': ['test', 'blub']})", + repr(res), + "incorrect repr for ParseResults with listAllMatches=True", + ) + def testWarnUsingLshiftForward(self): import warnings |