diff options
author | ptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b> | 2016-08-05 18:11:33 +0000 |
---|---|---|
committer | ptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b> | 2016-08-05 18:11:33 +0000 |
commit | 18e800d48d3e1c5298c11ae1dce9a6517bad7fd9 (patch) | |
tree | 431e0f3b16264e4bff5c360668cdb2a3db565d27 | |
parent | c4ebbf1551e743122815aa0af3a45b3ecb5528d1 (diff) | |
download | pyparsing-18e800d48d3e1c5298c11ae1dce9a6517bad7fd9.tar.gz |
Updated traceParseAction to use repr of input/output tokens instead of str
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@385 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-rw-r--r-- | src/CHANGES | 14 | ||||
-rw-r--r-- | src/pyparsing.py | 6 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/CHANGES b/src/CHANGES index ea7274e..877114f 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -21,6 +21,20 @@ Version 2.1.6 - indicator of its internal conversion of parsed values to floats,
while the generic "number" is similar to the flexible number syntax
in other languages.
+
+- Updated traceParseAction parse action decorator to show the repr
+ of the input and output tokens, instead of the str format, since
+ str has been simplified to just show the token list content.
+
+ (The change to ParseResults.__str__ occurred in pyparsing 2.0.4, but
+ it seems that didn't make it into the release notes - sorry! Too
+ many users, especially beginners, were confused by the
+ "([token_list], {names_dict})" str format for ParseResults, thinking
+ they were getting a tuple containing a list and a dict. The full form
+ can be seen if using repr().)
+
+ 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.
diff --git a/src/pyparsing.py b/src/pyparsing.py index a6e4f3b..9f637c6 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 17:50 UTC"
+__versionTime__ = "05 Aug 2016 18:01 UTC"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -3423,13 +3423,13 @@ def traceParseAction(f): s,l,t = paArgs[-3:]
if len(paArgs)>3:
thisFunc = paArgs[0].__class__.__name__ + '.' + thisFunc
- sys.stderr.write( ">>entering %s(line: '%s', %d, %s)\n" % (thisFunc,line(l,s),l,t) )
+ sys.stderr.write( ">>entering %s(line: '%s', %d, %r)\n" % (thisFunc,line(l,s),l,t) )
try:
ret = f(*paArgs)
except Exception as exc:
sys.stderr.write( "<<leaving %s (exception: %s)\n" % (thisFunc,exc) )
raise
- sys.stderr.write( "<<leaving %s (ret: %s)\n" % (thisFunc,ret) )
+ sys.stderr.write( "<<leaving %s (ret: %r)\n" % (thisFunc,ret) )
return ret
try:
z.__name__ = f.__name__
|