summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2012-12-16 08:02:59 +0000
committerptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2012-12-16 08:02:59 +0000
commitd10bcd6ebc7725fbe7cd9e4df01d068d54b31820 (patch)
tree48d93ae9cc79b9262ae79050e9487391de52917b
parentad13b88dcb730754d196a1fc4bfae97d5f78b696 (diff)
downloadpyparsing-d10bcd6ebc7725fbe7cd9e4df01d068d54b31820.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
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@252 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-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