Map `ssl.SSLError` to `ReadError` and `WriteError` in `AnyIOStream`

Merged
KL
18h ago
+69-0

Add ssl.SSLError to the exception mappings in AnyIOStream.read() (ReadError) and AnyIOStream.write() (WriteError).

anyio.streams.tls.TLSStream only translates SSLSyscallError and SSLEOFError, re-raising other ssl.SSLErrors (such as mid-stream record layer / bad MAC alerts) raw. AnyIOStream.start_tls() already mapped ssl.SSLError to ConnectError, and both SyncStream (via OSError) and TrioStream (via trio.SSLStream wrapping ssl.SSLError in BrokenResourceError) already mapped mid-stream TLS errors to ReadError / WriteError, leaving AnyIOStream.read() and write() as the only paths leaking raw ssl.SSLError.

Addresses the mid-stream ssl.SSLError leak reported in #854.

Session: pi --session 01a24058-cc48-76fc-a013-84da8cb42ccf