Issue #10429: IMAP.starttls() stored the capabilities as bytes objects,
rather than strings.
This commit is contained in:
parent
36c0dbc9be
commit
dbe7519da9
|
@ -196,13 +196,7 @@ class IMAP4:
|
||||||
else:
|
else:
|
||||||
raise self.error(self.welcome)
|
raise self.error(self.welcome)
|
||||||
|
|
||||||
typ, dat = self.capability()
|
self._get_capabilities()
|
||||||
if dat == [None]:
|
|
||||||
raise self.error('no CAPABILITY response from server')
|
|
||||||
dat = str(dat[-1], "ASCII")
|
|
||||||
dat = dat.upper()
|
|
||||||
self.capabilities = tuple(dat.split())
|
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
if self.debug >= 3:
|
if self.debug >= 3:
|
||||||
self._mesg('CAPABILITIES: %r' % (self.capabilities,))
|
self._mesg('CAPABILITIES: %r' % (self.capabilities,))
|
||||||
|
@ -737,10 +731,7 @@ class IMAP4:
|
||||||
self.sock = ssl_context.wrap_socket(self.sock)
|
self.sock = ssl_context.wrap_socket(self.sock)
|
||||||
self.file = self.sock.makefile('rb')
|
self.file = self.sock.makefile('rb')
|
||||||
self._tls_established = True
|
self._tls_established = True
|
||||||
typ, dat = self.capability()
|
self._get_capabilities()
|
||||||
if dat == [None]:
|
|
||||||
raise self.error('no CAPABILITY response from server')
|
|
||||||
self.capabilities = tuple(dat[-1].upper().split())
|
|
||||||
else:
|
else:
|
||||||
raise self.error("Couldn't establish TLS session")
|
raise self.error("Couldn't establish TLS session")
|
||||||
return self._untagged_response(typ, dat, name)
|
return self._untagged_response(typ, dat, name)
|
||||||
|
@ -956,6 +947,15 @@ class IMAP4:
|
||||||
return typ, data
|
return typ, data
|
||||||
|
|
||||||
|
|
||||||
|
def _get_capabilities(self):
|
||||||
|
typ, dat = self.capability()
|
||||||
|
if dat == [None]:
|
||||||
|
raise self.error('no CAPABILITY response from server')
|
||||||
|
dat = str(dat[-1], "ASCII")
|
||||||
|
dat = dat.upper()
|
||||||
|
self.capabilities = tuple(dat.split())
|
||||||
|
|
||||||
|
|
||||||
def _get_response(self):
|
def _get_response(self):
|
||||||
|
|
||||||
# Read response and store.
|
# Read response and store.
|
||||||
|
|
|
@ -208,6 +208,8 @@ class RemoteIMAPTest(unittest.TestCase):
|
||||||
self.server.logout()
|
self.server.logout()
|
||||||
|
|
||||||
def test_logincapa(self):
|
def test_logincapa(self):
|
||||||
|
for cap in self.server.capabilities:
|
||||||
|
self.assertIsInstance(cap, str)
|
||||||
self.assertTrue('LOGINDISABLED' in self.server.capabilities)
|
self.assertTrue('LOGINDISABLED' in self.server.capabilities)
|
||||||
self.assertTrue('AUTH=ANONYMOUS' in self.server.capabilities)
|
self.assertTrue('AUTH=ANONYMOUS' in self.server.capabilities)
|
||||||
rs = self.server.login(self.username, self.password)
|
rs = self.server.login(self.username, self.password)
|
||||||
|
@ -228,6 +230,8 @@ class RemoteIMAP_STARTTLSTest(RemoteIMAPTest):
|
||||||
self.assertEqual(rs[0], 'OK')
|
self.assertEqual(rs[0], 'OK')
|
||||||
|
|
||||||
def test_logincapa(self):
|
def test_logincapa(self):
|
||||||
|
for cap in self.server.capabilities:
|
||||||
|
self.assertIsInstance(cap, str)
|
||||||
self.assertFalse('LOGINDISABLED' in self.server.capabilities)
|
self.assertFalse('LOGINDISABLED' in self.server.capabilities)
|
||||||
|
|
||||||
|
|
||||||
|
@ -237,6 +241,8 @@ class RemoteIMAP_SSLTest(RemoteIMAPTest):
|
||||||
imap_class = IMAP4_SSL
|
imap_class = IMAP4_SSL
|
||||||
|
|
||||||
def test_logincapa(self):
|
def test_logincapa(self):
|
||||||
|
for cap in self.server.capabilities:
|
||||||
|
self.assertIsInstance(cap, str)
|
||||||
self.assertFalse('LOGINDISABLED' in self.server.capabilities)
|
self.assertFalse('LOGINDISABLED' in self.server.capabilities)
|
||||||
self.assertTrue('AUTH=PLAIN' in self.server.capabilities)
|
self.assertTrue('AUTH=PLAIN' in self.server.capabilities)
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #10429: IMAP.starttls() stored the capabilities as bytes objects,
|
||||||
|
rather than strings.
|
||||||
|
|
||||||
|
|
||||||
What's New in Python 3.2 Alpha 4?
|
What's New in Python 3.2 Alpha 4?
|
||||||
=================================
|
=================================
|
||||||
|
|
Loading…
Reference in New Issue