Skip to content

bpo-29970: Make ssh_handshake_timeout None by default#4939

Merged
asvetlov merged 7 commits intopython:masterfrom
asvetlov:ssl_handshake_timeout
Dec 20, 2017
Merged

bpo-29970: Make ssh_handshake_timeout None by default#4939
asvetlov merged 7 commits intopython:masterfrom
asvetlov:ssl_handshake_timeout

Conversation

@asvetlov
Copy link
Contributor

@asvetlov asvetlov commented Dec 20, 2017

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

https://bugs.python.org/issue29970

Add a check for passing the parameter only with ssl context.
@asvetlov asvetlov requested a review from 1st1 as a code owner December 20, 2017 10:36
@asvetlov asvetlov changed the title Make ssh_handshake_timeout None by default. bpo-29970: Make ssh_handshake_timeout None by default Dec 20, 2017
@asvetlov asvetlov self-assigned this Dec 20, 2017

if ssl_handshake_timeout is not None and not ssl:
raise ValueError(
'ssl_handshake_timeout is only meaningfu with ssl')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meaningfu -> meaningful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@1st1
Copy link
Member

1st1 commented Dec 20, 2017

BTW, what happens if someone passes ssl_handshake_timeout=0.0? Do we need to explicitly prohibit this?

@asvetlov
Copy link
Contributor Author

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.

@1st1
Copy link
Member

1st1 commented Dec 20, 2017

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.

@1st1
Copy link
Member

1st1 commented Dec 20, 2017

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.

@asvetlov
Copy link
Contributor Author

Ok, will add a code for raising

@asvetlov
Copy link
Contributor Author

Done

sslcontext = test_utils.dummy_ssl_context()
app_proto = mock.Mock()
waiter = mock.Mock()
with self.assertRaises(ValueError):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertRaisesRegex

@1st1
Copy link
Member

1st1 commented Dec 20, 2017

Wait, please use assertRaisesRegex to validate part of the error message. ValueError can be raised from anywhere, and sometimes assertRaises tests something entirely different.

@asvetlov asvetlov merged commit 51eb1c6 into python:master Dec 20, 2017
@asvetlov asvetlov deleted the ssl_handshake_timeout branch December 20, 2017 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants