Skip to content

gh-127667: refactor and improve _hashopenssl.c error branches - #131145

Merged
picnixz merged 7 commits into
python:mainfrom
picnixz:fix/hashlib/refactor-error-branches-127667
Mar 17, 2025
Merged

picnixz merged 7 commits into
python:mainfrom
picnixz:fix/hashlib/refactor-error-branches-127667

Conversation

@picnixz

@picnixz picnixz commented Mar 12, 2025 •

Copy link
Copy Markdown
Member

Previously, we had a single _setException() helper and most of the time, we always did the same thing. Sometimes it's also not necessary to actually create a va_list.

@picnixz
picnixz marked this pull request as ready for review March 13, 2025 10:34
@picnixz
picnixz requested review from gpshead and tiran as code owners March 13, 2025 10:34
@picnixz picnixz added needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes labels Mar 16, 2025
@picnixz

picnixz commented Mar 16, 2025

Copy link
Copy Markdown
Member Author

I'm backporting this because future changes will likely have conflicts since error branches would be handled differently.

@gpshead gpshead left a comment

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.

thanks, nice refactoring for better maintainability.

@picnixz picnixz self-assigned this Mar 16, 2025
@picnixz
picnixz merged commit ac50ece into python:main Mar 17, 2025
@miss-islington-app

Copy link
Copy Markdown

Thanks @picnixz for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

@picnixz
picnixz deleted the fix/hashlib/refactor-error-branches-127667 branch March 17, 2025 10:13
@miss-islington-app

Copy link
Copy Markdown

Sorry, @picnixz, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker ac50ece6cea8745834e4ec0a9617809a51245bfc 3.13
@miss-islington-app

Copy link
Copy Markdown

Sorry, @picnixz, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker ac50ece6cea8745834e4ec0a9617809a51245bfc 3.12
picnixz added a commit to picnixz/cpython that referenced this pull request Mar 17, 2025
…python#131145)

Refactor `_setException()` into different helpers that can be used separately:

- set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code.
- raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message.
- notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message.
@bedevere-app

bedevere-app Bot commented Mar 17, 2025

Copy link
Copy Markdown

GH-131347 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Mar 17, 2025
picnixz added a commit to picnixz/cpython that referenced this pull request Mar 17, 2025
…python#131145)

Refactor `_setException()` into different helpers that can be used separately:

- set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code.
- raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message.
- notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message.

# Conflicts:
#	Modules/_hashopenssl.c
@bedevere-app

bedevere-app Bot commented Mar 17, 2025

Copy link
Copy Markdown

GH-131348 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Mar 17, 2025
plashchynski pushed a commit to plashchynski/cpython that referenced this pull request Mar 17, 2025
…python#131145)

Refactor `_setException()` into different helpers that can be used separately:

- set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code.
- raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message.
- notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message.
picnixz added a commit that referenced this pull request Mar 18, 2025
#131145) (#131348)

gh-127667: refactor and improve `_hashopenssl.c` error branches (#131145)

Refactor `_setException()` into different helpers that can be used separately:

- set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code.
- raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message.
- notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message.

(cherry-picked from commit ac50ece).
picnixz added a commit that referenced this pull request Mar 18, 2025
#131145) (#131347)

gh-127667: refactor and improve `_hashopenssl.c` error branches (#131145)

Refactor `_setException()` into different helpers that can be used separately:

- set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code.
- raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message.
- notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message.

(cherry-picked from commit ac50ece).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants