mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
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. ........
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user