Commit 9d063895 authored by Georg Brandl's avatar Georg Brandl

Patch #1605192: list allowed states in error messages for imaplib.

parent 980049c6
...@@ -746,8 +746,10 @@ class IMAP4: ...@@ -746,8 +746,10 @@ class IMAP4:
if not command in Commands: if not command in Commands:
raise self.error("Unknown IMAP4 UID command: %s" % command) raise self.error("Unknown IMAP4 UID command: %s" % command)
if self.state not in Commands[command]: if self.state not in Commands[command]:
raise self.error('command %s illegal in state %s' raise self.error("command %s illegal in state %s, "
% (command, self.state)) "only allowed in states %s" %
(command, self.state,
', '.join(Commands[command])))
name = 'UID' name = 'UID'
typ, dat = self._simple_command(name, command, *args) typ, dat = self._simple_command(name, command, *args)
if command in ('SEARCH', 'SORT'): if command in ('SEARCH', 'SORT'):
...@@ -811,8 +813,10 @@ class IMAP4: ...@@ -811,8 +813,10 @@ class IMAP4:
if self.state not in Commands[name]: if self.state not in Commands[name]:
self.literal = None self.literal = None
raise self.error( raise self.error("command %s illegal in state %s, "
'command %s illegal in state %s' % (name, self.state)) "only allowed in states %s" %
(name, self.state,
', '.join(Commands[name])))
for typ in ('OK', 'NO', 'BAD'): for typ in ('OK', 'NO', 'BAD'):
if typ in self.untagged_responses: if typ in self.untagged_responses:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment