mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-24 03:29:28 +01:00
Allow wrappers to set the allowExtra value.
This commit is contained in:
parent
31d71b1a8e
commit
6d62500a07
@ -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)
|
||||||
context(irc, msg, args, state)
|
try:
|
||||||
if args and not self.allowExtra:
|
context(irc, msg, args, state)
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user