]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patch #1605192: list allowed states in error messages for imaplib.
authorGeorg Brandl <georg@python.org>
Tue, 13 Mar 2007 18:24:40 +0000 (18:24 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 13 Mar 2007 18:24:40 +0000 (18:24 +0000)
Lib/imaplib.py

index 08e15207a43df089a78eeb5c507128ce1670d36d..e30ae39bdb283ad1175f9843089f778f62b1d8c7 100644 (file)
@@ -746,8 +746,10 @@ class IMAP4:
         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, "
+                             "only allowed in states %s" %
+                             (command, self.state,
+                              ', '.join(Commands[command])))
         name = 'UID'
         typ, dat = self._simple_command(name, command, *args)
         if command in ('SEARCH', 'SORT'):
@@ -811,8 +813,10 @@ class IMAP4:
 
         if self.state not in Commands[name]:
             self.literal = None
-            raise self.error(
-            'command %s illegal in state %s' % (name, self.state))
+            raise self.error("command %s illegal in state %s, "
+                             "only allowed in states %s" %
+                             (name, self.state,
+                              ', '.join(Commands[name])))
 
         for typ in ('OK', 'NO', 'BAD'):
             if typ in self.untagged_responses: