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: Simplify version_info setup
  • Loading branch information
AA-Turner committed May 8, 2025
commit 7ea1ac158ec0b05d7b57b5bc4367d783e7651931
26 changes: 7 additions & 19 deletions Modules/_zstd/_zstdmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,37 +612,25 @@ add_parameters(PyObject *module)
return 0;
}

static inline PyObject *
get_zstd_version_info(void)
{
uint32_t ver = ZSTD_versionNumber();
uint32_t major, minor, release;

major = ver / 10000;
minor = (ver / 100) % 100;
release = ver % 100;

return Py_BuildValue("III", major, minor, release);
}

static inline int
add_vars_to_module(PyObject *module)
{
PyObject *obj;

/* zstd_version, a str. */
/* zstd_version, str */
if (PyModule_AddStringConstant(module, "zstd_version",
ZSTD_versionString()) < 0) {
return -1;
}

/* zstd_version_info, a tuple. */
obj = get_zstd_version_info();
if (PyModule_AddObjectRef(module, "zstd_version_info", obj) < 0) {
Py_XDECREF(obj);
/* zstd_version_info, tuple of (int, int, int) */
PyObject *vi = Py_BuildValue("BBB", ZSTD_VERSION_MAJOR, ZSTD_VERSION_MINOR,
ZSTD_VERSION_RELEASE);
if (PyModule_AddObjectRef(module, "zstd_version_info", vi) < 0) {
Py_XDECREF(vi);
return -1;
}
Py_DECREF(obj);
Py_DECREF(vi);

/* Add zstd parameters */
if (add_parameters(module) < 0) {
Expand Down
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