changeset b6ef0080edf2 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=b6ef0080edf2 description: Few fixes for the command system
diffstat:
src/commands/framework.py | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-)
diffs (32 lines):
diff -r 27317648a081 -r b6ef0080edf2 src/commands/framework.py --- a/src/commands/framework.py Thu Sep 17 04:38:39 2009 +0300 +++ b/src/commands/framework.py Thu Sep 17 09:03:57 2009 +0300 @@ -65,6 +65,11 @@ # unless it is already set by the one who raised an exception. if not exception.command and not exception.name: raise CommandError(exception.message, self) + + # Do not forget to re-raise an exception just like it was if at + # least either, command or name attribute is set properly. + raise + # This one is a little bit too wide, but as Python does not have # anything more constrained - there is no other choice. Take a look here # if command complains about invalid arguments while they are ok. @@ -603,8 +608,14 @@ for key, value in opts: initial = norm_kwargs.get(key) if isinstance(initial, (TupleType, ListType)) and value not in initial: - if value: - raise CommandError("Wrong argument", command) + raise CommandError("Wrong argument", command) + + # Detect every switch and ensure it will not receive any arguments. + # Normally this does not happen unless overlapping is enabled. + for key, value in opts: + initial = norm_kwargs.get(key) + if isinstance(initial, BooleanType) and not isinstance(value, BooleanType): + raise CommandError("Switches do not take arguments", command)
# We need to encode every keyword argument to a simple string, not the # unicode one, because ** expansion does not support it.