]> granicus.if.org Git - python/commitdiff
Try to fix test_imaplib failure
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 10 Nov 2010 00:02:28 +0000 (00:02 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 10 Nov 2010 00:02:28 +0000 (00:02 +0000)
Lib/imaplib.py

index e020747e6ce098610f94378930f3424dddae4b3d..94f4e8fdf5def8391cf6beacf6af2ccd81ae9a35 100644 (file)
@@ -818,7 +818,7 @@ class IMAP4:
     def _check_bye(self):
         bye = self.untagged_responses.get('BYE')
         if bye:
-            raise self.abort(bye[-1])
+            raise self.abort(bye[-1].decode('ascii', 'replace'))
 
 
     def _command(self, name, *args):
@@ -899,14 +899,17 @@ class IMAP4:
 
 
     def _command_complete(self, name, tag):
-        self._check_bye()
+        # BYE is expected after LOGOUT
+        if name != 'LOGOUT':
+            self._check_bye()
         try:
             typ, data = self._get_tagged_response(tag)
         except self.abort as val:
             raise self.abort('command: %s => %s' % (name, val))
         except self.error as val:
             raise self.error('command: %s => %s' % (name, val))
-        self._check_bye()
+        if name != 'LOGOUT':
+            self._check_bye()
         if typ == 'BAD':
             raise self.error('%s command error: %s %s' % (name, typ, data))
         return typ, data