mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-140634: Fix a reference counting bug in os.sched_param.__reduce__() (GH-140667)
This commit is contained in:
parent
a716091227
commit
364ae607d8
3 changed files with 10 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Fix a reference counting bug in :meth:`!os.sched_param.__reduce__`.
|
||||
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue