diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2018-09-24 23:25:51 -0500 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2018-09-24 23:25:51 -0500 |
commit | 54728a0f0c68c77272b8f5c9b82e3bcac12f8ee4 (patch) | |
tree | e7237235ff96daa5c19086bb165111e3917720e4 | |
parent | 5241985c6eb694358995d82761cb4d05f448bcd8 (diff) | |
download | pyparsing-git-54728a0f0c68c77272b8f5c9b82e3bcac12f8ee4.tar.gz |
Issue #28, bug in SkipTo when skipping to an expr that saves as a list
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | pyparsing.py | 6 | ||||
-rw-r--r-- | unitTests.py | 8 |
3 files changed, 17 insertions, 3 deletions
@@ -4,6 +4,12 @@ Change Log Version 2.x.x - TBD
-------------------
+- Fixed bug in SkipTo, if a SkipTo expression that was skipping to
+ an expression that returned a list (such as an And), and the
+ SkipTo was saved as a named result, the named result could be
+ saved as a ParseResults - should always be saved as a string.
+ Issue #28, reported by seron.
+
- Added simple_unit_tests.py, as a collection of easy-to-follow unit
tests for various classes and features of the pyparsing library.
Primary intent is more to be instructional than actually rigorous
diff --git a/pyparsing.py b/pyparsing.py index cf75e1e..5b9b1e7 100644 --- a/pyparsing.py +++ b/pyparsing.py @@ -74,8 +74,8 @@ classes inherit from. Use the docstrings for examples of how to: - find more useful common expressions in the L{pyparsing_common} namespace class
"""
-__version__ = "2.2.1"
-__versionTime__ = "18 Sep 2018 00:49 UTC"
+__version__ = "2.2.2"
+__versionTime__ = "25 Sep 2018 04:18 UTC"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -4084,7 +4084,7 @@ class SkipTo(ParseElementEnhance): self.mayReturnEmpty = True
self.mayIndexError = False
self.includeMatch = include
- self.asList = False
+ self.saveAsList = False
if isinstance(failOn, basestring):
self.failOn = ParserElement._literalStringClass(failOn)
else:
diff --git a/unitTests.py b/unitTests.py index a31bf40..a165e39 100644 --- a/unitTests.py +++ b/unitTests.py @@ -985,6 +985,14 @@ class SkipToParserTests(ParseTestCase): tryToParse('some text /* comment with ; in */; working')
tryToParse('some text /* comment with ; in */some other stuff; working', fail_expected=True)
+ # test that we correctly create named results
+ text = "prefixDATAsuffix"
+ data = Literal("DATA")
+ suffix = Literal("suffix")
+ expr = SkipTo(data + suffix)('prefix') + data + suffix
+ result = expr.parseString(text)
+ assert isinstance(result.prefix, str), "SkipTo created with wrong saveAsList attribute"
+
class CustomQuotesTest(ParseTestCase):
def runTest(self):
from pyparsing import QuotedString
|