Issue #10280: NNTP.nntp_version should reflect the highest version

advertised by the server.
This commit is contained in:
Antoine Pitrou 2010-11-02 22:31:52 +00:00
parent e159422ce9
commit f80b3f72c6
3 changed files with 9 additions and 4 deletions

View File

@ -361,7 +361,9 @@ class _NNTPBase:
else: else:
self._caps = caps self._caps = caps
if 'VERSION' in caps: if 'VERSION' in caps:
self.nntp_version = int(caps['VERSION'][0]) # The server can advertise several supported versions,
# choose the highest.
self.nntp_version = max(map(int, caps['VERSION']))
def getwelcome(self): def getwelcome(self):
"""Get the welcome message from the server """Get the welcome message from the server

View File

@ -558,7 +558,7 @@ class NNTPv2Handler(NNTPv1Handler):
def handle_CAPABILITIES(self): def handle_CAPABILITIES(self):
self.push_lit("""\ self.push_lit("""\
101 Capability list: 101 Capability list:
VERSION 2 VERSION 2 3
IMPLEMENTATION INN 2.5.1 IMPLEMENTATION INN 2.5.1
AUTHINFO USER AUTHINFO USER
HDR HDR
@ -935,7 +935,7 @@ class NNTPv2Tests(NNTPv1v2TestsMixin, MockedNNTPTestsMixin, unittest.TestCase):
def test_caps(self): def test_caps(self):
caps = self.server.getcapabilities() caps = self.server.getcapabilities()
self.assertEqual(caps, { self.assertEqual(caps, {
'VERSION': ['2'], 'VERSION': ['2', '3'],
'IMPLEMENTATION': ['INN', '2.5.1'], 'IMPLEMENTATION': ['INN', '2.5.1'],
'AUTHINFO': ['USER'], 'AUTHINFO': ['USER'],
'HDR': [], 'HDR': [],
@ -945,7 +945,7 @@ class NNTPv2Tests(NNTPv1v2TestsMixin, MockedNNTPTestsMixin, unittest.TestCase):
'POST': [], 'POST': [],
'READER': [], 'READER': [],
}) })
self.assertEqual(self.server.nntp_version, 2) self.assertEqual(self.server.nntp_version, 3)
class MiscTests(unittest.TestCase): class MiscTests(unittest.TestCase):

View File

@ -59,6 +59,9 @@ Core and Builtins
Library Library
------- -------
- Issue #10280: NNTP.nntp_version should reflect the highest version
advertised by the server.
- Issue #10184: Touch directories only once when extracting a tarfile. - Issue #10184: Touch directories only once when extracting a tarfile.
- Issue #10199: New package, ``turtledemo`` now contains selected demo - Issue #10199: New package, ``turtledemo`` now contains selected demo