]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 87230 via svnmerge from
authorR. David Murray <rdmurray@bitdance.com>
Tue, 14 Dec 2010 14:27:27 +0000 (14:27 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Tue, 14 Dec 2010 14:27:27 +0000 (14:27 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r87230 | r.david.murray | 2010-12-14 09:16:20 -0500 (Tue, 14 Dec 2010) | 7 lines

  #10695: use %s not %d so that a string 'port' does not cause a debug traceback

  Passing the port as a string value works fine in regular mode, but
  if you turned debug on it would throw an error trying to print the
  port number, which is surprising and confusing.
........

Lib/telnetlib.py
Lib/test/test_telnetlib.py
Misc/NEWS

index c60578debff52efde75b8afe2c9b23870475fe5b..82b5e8fc1b11b2bb52f015e5154dfc5e88d1dd02 100644 (file)
@@ -236,7 +236,7 @@ class Telnet:
 
         """
         if self.debuglevel > 0:
-            print('Telnet(%s,%d):' % (self.host, self.port), end=' ')
+            print('Telnet(%s,%s):' % (self.host, self.port), end=' ')
             if args:
                 print(msg % args)
             else:
index 3f5976b3f850094e2c8c3603ed3b00044a381963..c1eea06571ddb00df42f6bb97a7b21d84b3a42b6 100644 (file)
@@ -342,6 +342,16 @@ class OptionTests(TestCase):
         expected = "send b'xxx'\n"
         self.assertTrue(expected in telnet._messages)
 
+    def test_debug_accepts_str_port(self):
+        # Issue 10695
+        with test_socket([]):
+            telnet = TelnetAlike('dummy', '0')
+            telnet._messages = ''
+        telnet.set_debuglevel(1)
+        telnet.msg('test')
+        self.assertRegexpMatches(telnet._messages, r'0.*test')
+
+
 def test_main(verbose=None):
     support.run_unittest(GeneralTests, ReadTests, WriteTests, OptionTests)
 
index b1b3b6ca6aac3234fa17d19e0e86b037f33de143..0f9a78539847810ae1cf85a02fa114ddb21ee002 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -17,6 +17,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #10695: passing the port as a string value to telnetlib no longer
+  causes debug mode to fail.
+
 - Issue #1078919: add_header now automatically RFC2231 encodes parameters
   that contain non-ascii values.