Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Mar 12, 2025

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 bugs and security fixes labels Mar 16, 2025
@picnixz
Copy link
Member Author

picnixz commented Mar 16, 2025

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

Copy link
Member

@gpshead gpshead left a comment

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
49 checks passed
@miss-islington-app
Copy link

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

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

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
Copy link

bedevere-app bot commented Mar 17, 2025

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 bugs and 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
Copy link

bedevere-app bot commented Mar 17, 2025

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).
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 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.
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.

2 participants