bpo-29970: Make ssh_handshake_timeout None by default by asvetlov · Pull Request #4939 · python/cpython
Float default prevents checking for passing ssh_handshake_timeout with plain socket connection.
Raise ValueError if ssh_handshake_timeout is specified without ssl.
Postfix for #4825
asvetlov
changed the title
Make ssh_handshake_timeout None by default.
bpo-29970: Make ssh_handshake_timeout None by default
|
|
||
| if ssl_handshake_timeout is not None and not ssl: | ||
| raise ValueError( | ||
| 'ssl_handshake_timeout is only meaningfu with ssl') |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meaningfu -> meaningful
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
BTW, what happens if someone passes ssl_handshake_timeout=0.0? Do we need to explicitly prohibit this?
zero and negative timeout is an error but I doubt if we should prohibit it: there still is a possibility to pass 1e-30 which is obviously wrong.
zero and negative timeout is an error but I doubt if we should prohibit it: there still is a possibility to pass 1e-30 which is obviously wrong.
In many APIs, passing 0.0 disables the mechanism, and that's why we should either disable the timeout, or raise an error. Otherwise it's just confusing.
I vote for raising an error for 0.0. There's no point in allowing to disable the timeout.
If someone passes 1e-10, it's them clearly wanting to get a TimeoutError, that's it.
1st1 approved these changes Dec 20, 2017
| sslcontext = test_utils.dummy_ssl_context() | ||
| app_proto = mock.Mock() | ||
| waiter = mock.Mock() | ||
| with self.assertRaises(ValueError): |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertRaisesRegex
Wait, please use assertRaisesRegex to validate part of the error message. ValueError can be raised from anywhere, and sometimes assertRaises tests something entirely different.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters