Skip to content

gh-148292: Update ssl._SSLSocket for OpenSSL 4#149102

Merged
vstinner merged 10 commits intopython:mainfrom
vstinner:ssl_got_eof_error
May 4, 2026
Merged

gh-148292: Update ssl._SSLSocket for OpenSSL 4#149102
vstinner merged 10 commits intopython:mainfrom
vstinner:ssl_got_eof_error

Conversation

@vstinner
Copy link
Copy Markdown
Member

@vstinner vstinner commented Apr 28, 2026

The _SSLSocket object now remembers if it gets an EOF error. In this case, read(), sendfile(), write() and do_handshake() method calls fail with SSLEOFError without calling the underlying OpenSSL function.

The _SSLSocket object now remembers if it gets an EOF error. In this
case, read(), sendfile() and write() method calls fail with
SSLEOFError without calling the underlying OpenSSL function.
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented Apr 28, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32472356 | 📁 Comparing 0f650cc against main (2b6a137)

  🔍 Preview build  

2 files changed
± download.html
± whatsnew/changelog.html

Comment thread Modules/_ssl.c Outdated
Comment thread Lib/test/test_ssl.py
Comment thread Lib/test/test_ssl.py
Comment thread Lib/test/test_ssl.py Outdated
Comment thread Misc/NEWS.d/next/Library/2026-04-28-17-47-55.gh-issue-148292.oIq3ml.rst Outdated
@@ -0,0 +1,7 @@
:mod:`ssl`: Update :class:`ssl.SSLSocket` for OpenSSL 4. The class now
remembers if it gets a :exc:`ssl.SSLEOFError`. In this case, following
:meth:`~ssl.SSLSocket.read`, :meth:`!sendfile`, :meth:`~ssl.SSLSocket.write`,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:meth:~ssl.SSLSocket.sendfile ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Using :meth:~ssl.SSLSocket.sendfile makes the documentation fails to build. It doesn't work since SSLSocket.sendfile() has no anchor at https://docs.python.org/dev/library/ssl.html#ssl.SSLSocket, but SSLSocket.sendfile() method is documented

@vstinner
Copy link
Copy Markdown
Member Author

@gpshead: Please review the updated PR.

Note: Before, I didn't want to use self.addCleanup(server.join) in the test since the server could hang. I added the timeout that you suggested on the socket and so the server should no longer hang on error.

Comment thread Misc/NEWS.d/next/Library/2026-04-28-17-47-55.gh-issue-148292.oIq3ml.rst Outdated
Comment thread Lib/test/test_ssl.py Outdated
Co-authored-by: Victor Stinner <vstinner@python.org>
@vstinner
Copy link
Copy Markdown
Member Author

@picnixz: Would you mind to review this change?

It would be nice to have OpenSSL 4 support in Python 3.15 beta1 (feature freeze is next Tuesday).

@vstinner vstinner merged commit 7b7fa3f into python:main May 4, 2026
54 checks passed
@vstinner vstinner deleted the ssl_got_eof_error branch May 4, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants