From 71211524f1e8e2b33015ae6d00541f2dec18acf6 Mon Sep 17 00:00:00 2001 From: ptmcg Date: Fri, 5 Aug 2016 19:38:41 +0000 Subject: Fixed bug in upcaseTokens and downcaseTokens introduced in 2.1.5, when the parse action was used in conjunction with results names git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@388 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b --- src/CHANGES | 11 ++++++++--- src/pyparsing.py | 4 ++-- src/unitTests.py | 5 +++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/CHANGES b/src/CHANGES index 6cc9934..0e48b21 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -20,7 +20,14 @@ Version 2.1.6 - respectively. I hope the "f" prefix of "fnumber" will be a better indicator of its internal conversion of parsed values to floats, while the generic "number" is similar to the flexible number syntax - in other languages. + in other languages. Also fixed a bug in pyparsing_common.numeric + (now renamed to pyparsing_common.number), integers were parsed and + returned as floats instead of being retained as ints. + +- Fixed bug in upcaseTokens and downcaseTokens introduced in 2.1.5, + when the parse action was used in conjunction with results names. + Reported by Steven Arcangeli from the dql project, thanks for your + patience, Steven! - Major change to docs! After seeing some comments on reddit about general issue with docs of Python modules, and thinking that I'm a @@ -55,8 +62,6 @@ Version 2.1.6 - For tracing tokens in and out of parse actions, the more complete repr form provides important information when debugging parse actions. - -- Fixed bug in pyparsing_common.numeric, integers were parsed as floats. Verison 2.1.5 - June, 2016 diff --git a/src/pyparsing.py b/src/pyparsing.py index 29c9d14..088cf26 100644 --- a/src/pyparsing.py +++ b/src/pyparsing.py @@ -58,7 +58,7 @@ The pyparsing module handles some of the problems that are typically vexing when """ __version__ = "2.1.6" -__versionTime__ = "05 Aug 2016 18:11 UTC" +__versionTime__ = "05 Aug 2016 19:32 UTC" __author__ = "Paul McGuire " import string @@ -3729,7 +3729,7 @@ def tokenMap(func, *args): parsed data to an integer using base 16. """ def pa(s,l,t): - t[:] = [func(tokn, *args) for tokn in t] + return [func(tokn, *args) for tokn in t] try: func_name = getattr(func, '__name__', diff --git a/src/unitTests.py b/src/unitTests.py index cddcaf1..a4c651f 100644 --- a/src/unitTests.py +++ b/src/unitTests.py @@ -1464,6 +1464,11 @@ class UpcaseDowncaseUnicode(ParseTestCase): uword = pp.Word(ualphas).setParseAction(pp.downcaseTokens) print_(uword.searchString(a)) + + kw = pp.Keyword('mykey', caseless=True).setParseAction(pp.upcaseTokens).setResultsName('rname') + ret = kw.parseString('mykey') + print(ret.rname) + assert ret.rname=='MYKEY', "failed to upcase with named result" if not IRON_PYTHON_ENV: #test html data -- cgit v1.2.1