]> granicus.if.org Git - python/commitdiff
Issue #10280: NNTP.nntp_version should reflect the highest version
authorAntoine Pitrou <solipsis@pitrou.net>
Tue, 2 Nov 2010 22:31:52 +0000 (22:31 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Tue, 2 Nov 2010 22:31:52 +0000 (22:31 +0000)
advertised by the server.

Lib/nntplib.py
Lib/test/test_nntplib.py
Misc/NEWS

index 409342c78cd910a17aeb6decb2468a877d08d202..b067d6b3dfc45f909eaf3c692a500506bcbc665b 100644 (file)
@@ -361,7 +361,9 @@ class _NNTPBase:
         else:
             self._caps = 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):
         """Get the welcome message from the server
index dd100ef62c5ab98d2a97ebe2cb0e0c060d9087ce..e62b240abbc8bed761c0c34f9dd6a45090dffc0f 100644 (file)
@@ -558,7 +558,7 @@ class NNTPv2Handler(NNTPv1Handler):
     def handle_CAPABILITIES(self):
         self.push_lit("""\
             101 Capability list:
-            VERSION 2
+            VERSION 2 3
             IMPLEMENTATION INN 2.5.1
             AUTHINFO USER
             HDR
@@ -935,7 +935,7 @@ class NNTPv2Tests(NNTPv1v2TestsMixin, MockedNNTPTestsMixin, unittest.TestCase):
     def test_caps(self):
         caps = self.server.getcapabilities()
         self.assertEqual(caps, {
-            'VERSION': ['2'],
+            'VERSION': ['2', '3'],
             'IMPLEMENTATION': ['INN', '2.5.1'],
             'AUTHINFO': ['USER'],
             'HDR': [],
@@ -945,7 +945,7 @@ class NNTPv2Tests(NNTPv1v2TestsMixin, MockedNNTPTestsMixin, unittest.TestCase):
             'POST': [],
             'READER': [],
             })
-        self.assertEqual(self.server.nntp_version, 2)
+        self.assertEqual(self.server.nntp_version, 3)
 
 
 class MiscTests(unittest.TestCase):
index ae95b13c963c889c48d4b7ef72fabcbddb1f649b..b97a181603d774764e2ea71a6d0d2efce3ae9849 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -59,6 +59,9 @@ Core and Builtins
 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 #10199: New package, ``turtledemo`` now contains selected demo