Skip to content

gh-158313: Clear the OpenSSL error queue when ssl raises OSError - #158333

Open
lazerg wants to merge 1 commit into
python:mainfrom
lazerg:fix-issue-158313
Open

lazerg wants to merge 1 commit into
python:mainfrom
lazerg:fix-issue-158313

Conversation

@lazerg

@lazerg lazerg commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

The two ERR_LIB_SYS branches in PySSL_SetError return early and skip the ERR_clear_error() call that every other path makes. The entry then stays on the thread's error queue, and SSL_get_error() picks it up on the next I/O call on any socket in that thread, so the same OSError is raised again and again. This clears the queue in both branches, like the e == 0 branch already does.

The test fails on main with BrokenPipeError from the second connection.

Fixes #158313

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.

ssl: PySSL_SetError leaves the ERR_LIB_SYS entry on the OpenSSL error queue, so every later SSL I/O on that thread fails with the same OSError

1 participant