Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions Lib/test/test_os/test_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,14 @@ def test_sched_param(self):
self.assertNotEqual(newparam, param)
self.assertEqual(newparam.sched_priority, 0)

@requires_sched
def test_bug_140634(self):
sched_priority = float('inf') # any new reference
param = posix.sched_param(sched_priority)
param.__reduce__()
del sched_priority, param # should not crash
support.gc_collect() # just to be sure

@unittest.skipUnless(hasattr(posix, "sched_rr_get_interval"), "no function")
def test_sched_rr_get_interval(self):
try:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a reference counting bug in :meth:`posix.sched_param.__reduce__`.
Copy link
Member

@efimov-mikhail efimov-mikhail Oct 27, 2025

Choose a reason for hiding this comment

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

WARNING: py:meth reference target not found: posix.sched_param.__reduce__

Maybe simple

``posix.sched_param.__reduce__`` 

would be enough?

2 changes: 1 addition & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8724,7 +8724,7 @@ os_sched_param_impl(PyTypeObject *type, PyObject *sched_priority)
static PyObject *
os_sched_param_reduce(PyObject *self, PyObject *Py_UNUSED(dummy))
{
return Py_BuildValue("(O(N))", Py_TYPE(self), PyStructSequence_GetItem(self, 0));
return Py_BuildValue("(O(O))", Py_TYPE(self), PyStructSequence_GetItem(self, 0));
}

static PyMethodDef os_sched_param_reduce_method = {
Expand Down
Loading