-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
ssl: Add missing constants & classes #1569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just one request for clarification.
stdlib/3/ssl.pyi
Outdated
@@ -168,6 +175,10 @@ class SSLSocket(socket.socket): | |||
context = ... # type: SSLContext | |||
server_side = ... # type: bool | |||
server_hostname = ... # type: Optional[str] | |||
if sys.version_info >= (3, 6): | |||
session = ... # type: SSLSession |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be Optional? It looks like they're None if self._sslobj
is None. But maybe we shouldn't worry too much about that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess they are technically optional since they only seem to be valid for in certain states (handshaken sockets).
That distinction is not represented in the type though, so it's somewhat of a philosophical question - for objects with different states, do we take the optimistic stance (assume that the object is in the right state) or make the client code always validate the state in strict mode (is not None
)...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense; I don't think I have a general answer here.
@@ -237,6 +248,9 @@ if sys.version_info >= (3, 5): | |||
context = ... # type: SSLContext | |||
server_side = ... # type: bool | |||
server_hostname = ... # type: Optional[str] | |||
if sys.version_info >= (3, 6): | |||
session = ... # type: Optional[SSLSession] | |||
session_reused = ... # type: bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can not return None
while the property above can... https://github.com/python/cpython/blob/5fe59f8e3a0a56a155c18f9d581205ec533764b6/Modules/_ssl.c#L2476
See commit messages for details about how these were derived.