summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-12-14 14:27:27 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-12-14 14:27:27 (GMT)
commit6b2af997d433a134d792d4b9b8f696da3cc9bb52 (patch)
tree08a0fe156b487daea11836bad6081c0350b3a3b1
parentd382066d2cf94f6f0d37ab85a8daeeb13feebe1d (diff)
downloadcpython-6b2af997d433a134d792d4b9b8f696da3cc9bb52.zip
cpython-6b2af997d433a134d792d4b9b8f696da3cc9bb52.tar.gz
cpython-6b2af997d433a134d792d4b9b8f696da3cc9bb52.tar.bz2
Merged revisions 87230 via svnmerge from
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. ........
-rw-r--r--Lib/telnetlib.py2
-rw-r--r--Lib/test/test_telnetlib.py10
-rw-r--r--Misc/NEWS3
3 files changed, 14 insertions, 1 deletions
diff --git a/Lib/telnetlib.py b/Lib/telnetlib.py
index c60578d..82b5e8f 100644
--- a/Lib/telnetlib.py
+++ b/Lib/telnetlib.py
@@ -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:
diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py
index 3f5976b..c1eea06 100644
--- a/Lib/test/test_telnetlib.py
+++ b/Lib/test/test_telnetlib.py
@@ -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)
diff --git a/Misc/NEWS b/Misc/NEWS
index b1b3b6c..0f9a785 100644
--- 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.