Skip to content

gh-132983: _zstd: use Py_UNREACHABLE in _zstd_load_impl #137320

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
merged 1 commit into from
Aug 4, 2025

Conversation

Rogdham
Copy link
Contributor

@Rogdham Rogdham commented Aug 2, 2025

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.


Copy link
Member

@emmatyping emmatyping left a comment

Choose a reason for hiding this comment

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

Thank you!

Copy link
Member

@ZeroIntensity ZeroIntensity left a 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?

Copy link
Member

@AA-Turner AA-Turner left a 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?

@ZeroIntensity
Copy link
Member

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.

@AA-Turner
Copy link
Member

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

@AA-Turner
Copy link
Member

Anyway, the compression path already uses Py_UNREACHABLE, so likely best to merge for pragmatism.

A

@AA-Turner AA-Turner merged commit 57eab1b into python:main Aug 4, 2025
54 checks passed
@miss-islington-app
Copy link

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!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 4, 2025
…honGH-137320)

(cherry picked from commit 57eab1b8f78039142d58d207d39ae734d67952cf)

Co-authored-by: Rogdham <3994389+Rogdham@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Aug 4, 2025

GH-137360 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Aug 4, 2025
@Rogdham Rogdham deleted the zstd_load_impl_pyunreachable branch August 4, 2025 06:27
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.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy