mirror of
https://github.com/python/cpython.git
synced 2025-11-25 12:44:13 +00:00
gh-108727: Fix segfault due to missing tp_dealloc definition for CounterOptimizer_Type (GH-108734)
This commit is contained in:
parent
044b8b3b6a
commit
844f4c2e12
3 changed files with 10 additions and 0 deletions
|
|
@ -2284,6 +2284,13 @@ def clear_executors(func):
|
||||||
|
|
||||||
class TestOptimizerAPI(unittest.TestCase):
|
class TestOptimizerAPI(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_get_counter_optimizer_dealloc(self):
|
||||||
|
# See gh-108727
|
||||||
|
def f():
|
||||||
|
_testinternalcapi.get_counter_optimizer()
|
||||||
|
|
||||||
|
f()
|
||||||
|
|
||||||
def test_get_set_optimizer(self):
|
def test_get_set_optimizer(self):
|
||||||
old = _testinternalcapi.get_optimizer()
|
old = _testinternalcapi.get_optimizer()
|
||||||
opt = _testinternalcapi.get_counter_optimizer()
|
opt = _testinternalcapi.get_counter_optimizer()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
Define ``tp_dealloc`` for ``CounterOptimizer_Type``. This fixes a segfault
|
||||||
|
on deallocation.
|
||||||
|
|
@ -289,6 +289,7 @@ static PyTypeObject CounterOptimizer_Type = {
|
||||||
.tp_itemsize = 0,
|
.tp_itemsize = 0,
|
||||||
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,
|
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,
|
||||||
.tp_methods = counter_methods,
|
.tp_methods = counter_methods,
|
||||||
|
.tp_dealloc = (destructor)PyObject_Del,
|
||||||
};
|
};
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue