GeezerVison is showing github.com — gh-132983: _zstd: use Py_UNREACHABLE in _zstd_load_impl by Rogdham · Pull Request #137320 · python/cpython
Conversation
Rogdham
commented
Aug 2, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
There are 2 functions called _zstd_load_impl: one for compression and one for decompression.
In these functions, the type variable is supposed to represent the dict type. Due to the way the function is called, the dict type is always one of DICT_TYPE_DIGESTED/DICT_TYPE_UNDIGESTED/DICT_TYPE_PREFIX. However, the implementations differs in the unreachable case:
This PR harmonizes the two implementations by using Py_UNREACHABLE.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as well.
@emmatyping Would you like to use your new green button?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
AA-Turner
left a comment
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to have a test that we don't hit this unreachable path?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Hm, how are you envisioning that? The whole point of Py_UNREACHABLE here is that no code path can hit it, so there's not really a test we could write to stress that.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I'm not a fan of needing logic like this, and it would be nice to exhaustively test that we never hit it, but I haven't had a good idea, no.
A
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Anyway, the compression path already uses Py_UNREACHABLE, so likely best to merge for pragmatism.
A
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks @Rogdham for the PR, and @AA-Turner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|