diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2019-07-20 13:44:16 -0500 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2019-07-20 13:44:16 -0500 |
commit | 07d82bb767d75a0a30bd6f806938c1f9fe50d8ee (patch) | |
tree | fcb1e297f3191111638df627bf657b90b2191c77 | |
parent | a6203b170a61bd4da24388fb14f83df481159981 (diff) | |
download | pyparsing-git-07d82bb767d75a0a30bd6f806938c1f9fe50d8ee.tar.gz |
Fix latent bug if adding a parse action after having cleared parse actions with Nonepyparsing_2.4.1
-rw-r--r-- | pyparsing.py | 4 | ||||
-rw-r--r-- | unitTests.py | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/pyparsing.py b/pyparsing.py index 0bdd8db..af0cff0 100644 --- a/pyparsing.py +++ b/pyparsing.py @@ -96,7 +96,7 @@ classes inherit from. Use the docstrings for examples of how to: """ __version__ = "2.4.1" -__versionTime__ = "16 Jul 2019 04:10 UTC" +__versionTime__ = "20 Jul 2019 18:17 UTC" __author__ = "Paul McGuire <ptmcg@users.sourceforge.net>" import string @@ -1542,7 +1542,7 @@ class ParserElement(object): date_str.parseString("1999/12/31") # -> [1999, '/', 12, '/', 31] """ if list(fns) == [None,]: - self.parseAction = None + self.parseAction = [] else: if not all(callable(fn) for fn in fns): raise TypeError("parse actions must be callable") diff --git a/unitTests.py b/unitTests.py index 0c1ebee..7bfbe52 100644 --- a/unitTests.py +++ b/unitTests.py @@ -3180,6 +3180,10 @@ class ClearParseActionsTest(ParseTestCase): realnum.setParseAction(None) self.assertEqual(realnum.parseString("3.14159")[0], "3.14159", "failed clearing parse action") + # add a new parse action that tests if a '.' is prsent + realnum.addParseAction(lambda t: '.' in t[0]) + self.assertEqual(realnum.parseString("3.14159")[0], True, + "failed setting new parse action after clearing parse action") class OneOrMoreStopTest(ParseTestCase): def runTest(self): |