[Pyparsing] keepOriginalText problem
Brought to you by:
ptmcg
From: stefaan <Ste...@gm...> - 2008-07-03 11:20:05
|
Hello, I have a problem with keepOriginalText: when I try to parse a grammar using the keepOriginalText parse action inside a cherrypy 2.2.1-based web application, the getTokensEndLoc() fails and I get a traceback: File "C:\shi\webapp\comparefiles\comparefiles.py", line 273, in doCompare NormalDiffParser.remove_lines.parseString("< line 1" + os.linesep + "< line 2" + os.linesep) File "C:\shi\webapp\comparefiles\diffparser\pyparsing.py", line 981, in parseString loc, tokens = self._parse( instring, 0 ) File "C:\shi\webapp\comparefiles\diffparser\pyparsing.py", line 886, in _parseNoCache tokens = fn( instring, tokensStart, retTokens ) File "C:\shi\webapp\comparefiles\diffparser\pyparsing.py", line 3156, in keepOriginalText endloc = getTokensEndLoc() File "C:\shi\webapp\comparefiles\diffparser\pyparsing.py", line 3167, in getTokensEndLoc fstack = inspect.stack() File "D:\Python24\lib\inspect.py", line 819, in stack return getouterframes(sys._getframe(1), context) File "D:\Python24\lib\inspect.py", line 800, in getouterframes framelist.append((frame,) + getframeinfo(frame, context)) File "D:\Python24\lib\inspect.py", line 769, in getframeinfo raise TypeError('arg is not a frame or traceback object') TypeError: arg is not a frame or traceback object The grammar for remove_lines: import pyparsing as remove_line = p.lineStart + p.Literal("<").suppress() + \ p.restOfLine.setResultsName("LineContents") + p.lineEnd remove_lines = p.Combine(p.OneOrMore(remove_line)) remove_lines.setParseAction(p.keepOriginalText) The same program, with the same input, works flawlessly in a "normal" (i.e. not webapplication) script. |