--- imaplib.py_orig 2006-11-29 12:43:35.149344178 +0100 +++ imaplib.py 2006-11-29 12:42:47.459835876 +0100 @@ -746,8 +746,8 @@ if not command in Commands: raise self.error("Unknown IMAP4 UID command: %s" % command) if self.state not in Commands[command]: - raise self.error('command %s illegal in state %s' - % (command, self.state)) + raise self.error('command %s illegal in state %s. Allowed after: %s' + % (command, self.state, ', '.join(Commands[command]))) name = 'UID' typ, dat = self._simple_command(name, command, *args) if command in ('SEARCH', 'SORT'): @@ -812,7 +812,8 @@ if self.state not in Commands[name]: self.literal = None raise self.error( - 'command %s illegal in state %s' % (name, self.state)) + 'command %s illegal in state %s. Allowed after: %s' % ( + name, self.state, ', '.join(Commands[name]))) for typ in ('OK', 'NO', 'BAD'): if typ in self.untagged_responses: