Allow wrappers to set the allowExtra value.

This commit is contained in:
Jeremy Fincher 2004-10-19 01:43:58 +00:00
parent 31d71b1a8e
commit 6d62500a07

View File

@ -679,6 +679,7 @@ class Spec(object):
def _state(self, types, attrs={}): def _state(self, types, attrs={}):
st = State(types) st = State(types)
st.__dict__.update(attrs) st.__dict__.update(attrs)
st.allowExtra = self.allowExtra
return st return st
def __init__(self, types, allowExtra=False): def __init__(self, types, allowExtra=False):
@ -690,8 +691,11 @@ class Spec(object):
state = self._state(self.types[:], stateAttrs) state = self._state(self.types[:], stateAttrs)
while state.types: while state.types:
context = state.types.pop(0) context = state.types.pop(0)
try:
context(irc, msg, args, state) context(irc, msg, args, state)
if args and not self.allowExtra: except IndexError:
raise callbacks.ArgumentError
if args and not state.allowExtra:
log.debug('args and not self.allowExtra: %r', args) log.debug('args and not self.allowExtra: %r', args)
raise callbacks.ArgumentError raise callbacks.ArgumentError
return state return state