8000 gh-132983: Clean-ups for `_zstd` by AA-Turner · Pull Request #133670 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-132983: Clean-ups for _zstd #133670

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 16 commits into from
May 9, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
zstd: factor common parts of set_zstd_error()
  • Loading branch information
AA-Turner committed May 8, 2025
commit e02f66cd87812cc4a60ba52ed1ec691b93a1ef22
23 changes: 12 additions & 11 deletions 23 Modules/_zstd/_zstdmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,44 @@ set_zstd_error(const _zstd_state* const state,
switch (type)
{
case ERR_DECOMPRESS:
msg = "Unable to decompress zstd data: %s";
msg = "decompress zstd data";
break;
case ERR_COMPRESS:
msg = "Unable to compress zstd data: %s";
msg = "compress zstd data";
break;
case ERR_SET_PLEDGED_INPUT_SIZE:
msg = "Unable to set pledged uncompressed content size: %s";
msg = "set pledged uncompressed content size";
break;

case ERR_LOAD_D_DICT:
msg = "Unable to load zstd dictionary or prefix for decompression: %s";
msg = "load zstd dictionary or prefix for decompression";
break;
case ERR_LOAD_C_DICT:
msg = "Unable to load zstd dictionary or prefix for compression: %s";
msg = "load zstd dictionary or prefix for compression";
break;

case ERR_GET_C_BOUNDS:
msg = "Unable to get zstd compression parameter bounds: %s";
msg = "get zstd compression parameter bounds";
break;
case ERR_GET_D_BOUNDS:
msg = "Unable to get zstd decompression parameter bounds: %s";
msg = "get zstd decompression parameter bounds";
break;
case ERR_SET_C_LEVEL:
msg = "Unable to set zstd compression level: %s";
msg = "set zstd compression level";
break;

case ERR_TRAIN_DICT:
msg = "Unable to train zstd dictionary: %s";
msg = "train zstd dictionary";
break;
case ERR_FINALIZE_DICT:
msg = "Unable to finalize zstd dictionary: %s";
msg = "finalize zstd dictionary";
break;

default:
Py_UNREACHABLE();
}
PyErr_Format(state->ZstdError, msg, ZSTD_getErrorName(zstd_ret));
PyErr_Format(state->ZstdError, "Unable to %s: %s",
msg, ZSTD_getErrorName(zstd_ret));
}

typedef struct {
Expand Down
0