FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-132983: _zstd: use Py_UNREACHABLE in _zstd_load_impl by Rogdham · Pull Request #137320 · python/cpython · GitHub

/ cpython Public

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

Merged
AA-Turner merged 1 commit into
python:mainfrom
Rogdham:zstd_load_impl_pyunreachable
Aug 4, 2025
Merged

gh-132983: _zstd: use Py_UNREACHABLE in _zstd_load_impl#137320
AA-Turner merged 1 commit into
python:mainfrom
Rogdham:zstd_load_impl_pyunreachable

Conversation

Rogdham commented Aug 2, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

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.


emmatyping 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you!

ZeroIntensity 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM as well.

@emmatyping Would you like to use your new green button?

AA-Turner left a comment
edited
Loading

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Does it make sense to have a test that we don't hit this unreachable path?

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

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

Copy link
Copy Markdown
Member

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

A

AA-Turner merged commit 57eab1b into python:main Aug 4, 2025
54 checks passed

Copy link
Copy Markdown

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 57eab1b)

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

bedevere-app Bot commented Aug 4, 2025

Copy link
Copy Markdown

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

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 4, 2025
Rogdham deleted the zstd_load_impl_pyunreachable branch August 4, 2025 06:27
hugovk pushed a commit that referenced this pull request Aug 7, 2025
…-137320) (#137360)

Co-authored-by: Rogdham <3994389+Rogdham@users.noreply.github.com>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
…`` (pythonGH-137320) (python#137360)

Co-authored-by: Rogdham <3994389+Rogdham@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL