Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-134885: zstd: Use Py_XSETREF #134886

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 2 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion Lib/test/test_ctypes/test_incomplete.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ctypes
import unittest
import warnings
Copy link
Contributor

Choose a reason for hiding this comment

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

Py_XSETREF() LGTM, but this ctypes correction looks like an accident.

Copy link
Member Author

Choose a reason for hiding this comment

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

CI was broken on main (the import is unused), and since it's a small change I figured I might as well include it

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the change is excluded from this PR since f49a07b already applied it, which is good for 3.14.

from ctypes import Structure, POINTER, pointer, c_char_p

# String-based "incomplete pointers" were implemented in ctypes 0.6.3 (2003, when
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix possible crash in the :mod:`compression.zstd` module related to setting
parameter types. Patch by Jelle Zijlstra.
11 changes: 4 additions & 7 deletions Modules/_zstd/_zstdmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,10 @@ _zstd_set_parameter_types_impl(PyObject *module, PyObject *c_parameter_type,
return NULL;
}

Py_XDECREF(mod_state->CParameter_type);
Py_INCREF(c_parameter_type);
mod_state->CParameter_type = (PyTypeObject*)c_parameter_type;

Py_XDECREF(mod_state->DParameter_type);
Py_INCREF(d_parameter_type);
mod_state->DParameter_type = (PyTypeObject*)d_parameter_type;
Py_XSETREF(
mod_state->CParameter_type, (PyTypeObject*)Py_NewRef(c_parameter_type));
Py_XSETREF(
mod_state->DParameter_type, (PyTypeObject*)Py_NewRef(d_parameter_type));

Py_RETURN_NONE;
}
Expand Down
Loading