From 6321ab369b4bb0087e257700a544364a85b0da02 Mon Sep 17 00:00:00 2001 From: ptmcg Date: Sun, 16 Dec 2012 08:03:22 +0000 Subject: 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/branches/pyparsing_1.5.x@253 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b --- src/pyparsing.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/pyparsing.py') diff --git a/src/pyparsing.py b/src/pyparsing.py index 7abb9c5..149ccaf 100644 --- a/src/pyparsing.py +++ b/src/pyparsing.py @@ -653,12 +653,15 @@ def _trim_arity(func, maxargs=2): if func in singleArgBuiltins: return lambda s,l,t: func(t) limit = [0] + foundArity = [False] def wrapper(*args): while 1: try: - return func(*args[limit[0]:]) + ret = func(*args[limit[0]:]) + foundArity[0] = True + return ret except TypeError: - if limit[0] <= maxargs: + if limit[0] <= maxargs and not foundArity[0]: limit[0] += 1 continue raise -- cgit v1.2.1