diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2016-05-11 14:43:42 +0000 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2016-05-11 14:43:42 +0000 |
commit | 24815a032cb96b5df1f80d265900f8a91634f674 (patch) | |
tree | 16c0b96dbfea11004ae29c8f0b26761b695b9a7b /src/pyparsing.py | |
parent | eddec15af7eea2e09e5e451aec223d4ed6a4b376 (diff) | |
download | pyparsing-git-24815a032cb96b5df1f80d265900f8a91634f674.tar.gz |
Fix trim_arity handling of Python 2 vs 3 traceback data; changed in 3.5, not 3.0, so earlier Py3 versions use data as-is from traceback module
Diffstat (limited to 'src/pyparsing.py')
-rw-r--r-- | src/pyparsing.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/pyparsing.py b/src/pyparsing.py index 988419b..917be82 100644 --- a/src/pyparsing.py +++ b/src/pyparsing.py @@ -57,8 +57,8 @@ The pyparsing module handles some of the problems that are typically vexing when - embedded comments
"""
-__version__ = "2.1.2"
-__versionTime__ = "29 Apr 2016 15:10 UTC"
+__version__ = "2.1.3"
+__versionTime__ = "11 May 2016 14:19 UTC"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -787,7 +787,8 @@ def _trim_arity(func, maxargs=2): limit = [0]
foundArity = [False]
- if PY_3:
+ # traceback return data structure changed in Py3.5 - normalize back to plain tuples
+ if tuple(sys.version_info) >= (3,5):
def extract_stack():
frame_summary = traceback.extract_stack()[-3]
return [(frame_summary.filename, frame_summary.lineno)]
@@ -802,11 +803,11 @@ def _trim_arity(func, maxargs=2): # synthesize what would be returned by traceback.extract_stack at the call to
# user's parse action 'func', so that we don't incur call penalty at parse time
+ LINE_DIFF = 6
# IF ANY CODE CHANGES, EVEN JUST COMMENTS OR BLANK LINES, BETWEEN THE NEXT LINE AND
- # THE CALL TO FUNC INSIDE WRAPPER, THE CONSTANT ADDED TO 'this_line[1]' BELOW
- # MUST BE MODIFIED!!!!
+ # THE CALL TO FUNC INSIDE WRAPPER, LINE_DIFF MUST BE MODIFIED!!!!
this_line = extract_stack()[-1]
- pa_call_line_synth = (this_line[0], this_line[1]+6)
+ pa_call_line_synth = (this_line[0], this_line[1]+LINE_DIFF)
def wrapper(*args):
while 1:
|