This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ssl blocking IO errors should inherit BlockingIOError
Type: Stage:
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: alex, christian.heimes, dstufft, giampaolo.rodola, h.venev, janssen, martin.panter, pitrou
Priority: normal Keywords:

Created on 2014-08-22 17:31 by h.venev, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg225687 - (view) Author: Hristo Venev (h.venev) * Date: 2014-08-22 17:31
ssl.SSLWantReadError and ssl.SSLWantWriteError should inherit io.BlockingIOError.

Generic code that works with non-blocking sockets will stop working with SSLSockets.

Does anybody have any idea if SSLSocket.read() will need to write to the underlying socket or SSLSocket.write() need to read from it? AFAIK they don't.

Assuming that ssl.SSLWantReadErorr and ssl.SSLWantWriteError perfectly map to io.BlockingIOError (except during handshake).
msg225718 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-08-23 00:32
> ssl.SSLWantReadError and ssl.SSLWantWriteError should inherit io.BlockingIOError.
> Generic code that works with non-blocking sockets will stop working with SSLSockets.

I'll have to think about that, but in any case non-blocking SSL code needs to be subtler than normal non-blocking code, because of this:

> Does anybody have any idea if SSLSocket.read() will need to write to the underlying socket or SSLSocket.write() need to read from it? AFAIK they don't.

Yet the documentation clearly tells you they can:
https://docs.python.org/3/library/ssl.html#notes-on-non-blocking-sockets
msg225734 - (view) Author: Hristo Venev (h.venev) * Date: 2014-08-23 07:02
My questions are:
When will SSLSocket.recv() raise SSLWantWriteError?
When will SSLSocket.send() raise SSLWantReadError?

According to my very basic knowledge abou the protocol, this will never happen.
msg225743 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-08-23 12:46
Le 23/08/2014 03:02, Hristo Venev a écrit :
> When will SSLSocket.recv() raise SSLWantWriteError?
> When will SSLSocket.send() raise SSLWantReadError?
>
> According to my very basic knowledge abou the protocol, this will never happen.

According to the OpenSSL docs:
"""As at any time a re-negotiation is possible, a call to SSL_write() 
can also cause read operations!"""
"""As at any time a re-negotiation is possible, a call to SSL_read() can 
also cause write operations!"""
msg275203 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2016-09-08 23:00
I agree with Antoine, let's not subclass io.BlockingIOError.
History
Date User Action Args
2022-04-11 14:58:07adminsetgithub: 66448
2016-09-08 23:00:04christian.heimessetstatus: open -> closed
resolution: wont fix
messages: + msg275203
2015-03-08 05:49:24martin.pantersetnosy: + martin.panter

title: ssl blocking IO errors -> ssl blocking IO errors should inherit BlockingIOError
2014-08-23 12:46:53pitrousetmessages: + msg225743
2014-08-23 07:02:08h.venevsetmessages: + msg225734
2014-08-23 00:32:20pitrousetnosy: + janssen, pitrou, giampaolo.rodola, christian.heimes, alex, dstufft
messages: + msg225718
2014-08-22 17:31:19h.venevcreate