[Python-checkins] r87230 - in python/branches/py3k: Lib/telnetlib.py Lib/test/test_telnetlib.py Misc/NEWS
r.david.murray
python-checkins at python.org
Tue Dec 14 15:16:20 CET 2010
Author: r.david.murray
Date: Tue Dec 14 15:16:20 2010
New Revision: 87230
Log:
#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.
Modified:
python/branches/py3k/Lib/telnetlib.py
python/branches/py3k/Lib/test/test_telnetlib.py
python/branches/py3k/Misc/NEWS
Modified: python/branches/py3k/Lib/telnetlib.py
==============================================================================
--- python/branches/py3k/Lib/telnetlib.py (original)
+++ python/branches/py3k/Lib/telnetlib.py Tue Dec 14 15:16:20 2010
@@ -236,7 +236,7 @@
"""
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:
Modified: python/branches/py3k/Lib/test/test_telnetlib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_telnetlib.py (original)
+++ python/branches/py3k/Lib/test/test_telnetlib.py Tue Dec 14 15:16:20 2010
@@ -342,6 +342,16 @@
expected = "send b'xxx'\n"
self.assertIn(expected, 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.assertRegex(telnet._messages, r'0.*test')
+
+
def test_main(verbose=None):
support.run_unittest(GeneralTests, ReadTests, WriteTests, OptionTests)
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Tue Dec 14 15:16:20 2010
@@ -11,6 +11,9 @@
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.
More information about the Python-checkins
mailing list