summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@austin.rr.com>2012-12-16 08:02:59 +0000
committerPaul McGuire <ptmcg@austin.rr.com>2012-12-16 08:02:59 +0000
commit15374a9cd4cf51cddbb0d5dd3e748be515975b7c (patch)
tree48d93ae9cc79b9262ae79050e9487391de52917b /src
parent98cb3a32ffa39b70bc7cfdf5f11636a87f45ed17 (diff)
downloadpyparsing-git-15374a9cd4cf51cddbb0d5dd3e748be515975b7c.tar.gz
Add latch to _trim_arity so that once the correct arg count has been found, future TypeErrors get correctly raised and don't continue to try updating the argcount
Diffstat (limited to 'src')
-rw-r--r--src/pyparsing.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/pyparsing.py b/src/pyparsing.py
index 4534ae2..e6d4c38 100644
--- a/src/pyparsing.py
+++ b/src/pyparsing.py
@@ -624,13 +624,16 @@ def _trim_arity(func, maxargs=3):
if func in singleArgBuiltins:
return lambda s,l,t: func(t)
limit = 0
+ foundArity = False
def wrapper(*args):
- nonlocal limit
+ nonlocal limit,foundArity
while 1:
try:
- return func(*args[limit:])
+ ret = func(*args[limit:])
+ foundArity = True
+ return ret
except TypeError:
- if limit == maxargs:
+ if limit == maxargs or foundArity:
raise
limit += 1
continue