diff options
author | Mark Shannon <mark@hotpy.org> | 2023-10-26 10:31:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-26 10:31:51 (GMT) |
commit | 5c9d4497abd2923b4655cee2510208be8540b117 (patch) | |
tree | eae5c8952156c9bb88eea6f845e537606469cb43 /Python | |
parent | 78e6d72e38ef4b490f0098b644454031f20ae361 (diff) | |
download | cpython-5c9d4497abd2923b4655cee2510208be8540b117.zip cpython-5c9d4497abd2923b4655cee2510208be8540b117.tar.gz cpython-5c9d4497abd2923b4655cee2510208be8540b117.tar.bz2 |
GH-111339: Change `valid` property of executors to `is_valid()` method (GH-111350)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/optimizer.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c index 3dfd4f3..b9aab46 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -225,9 +225,15 @@ counter_dealloc(_PyCounterExecutorObject *self) { PyObject_Free(self); } -static PyMemberDef counter_members[] = { - { "valid", Py_T_UBYTE, offsetof(_PyCounterExecutorObject, executor.vm_data.valid), Py_READONLY, "is valid?" }, - { NULL } +static PyObject * +is_valid(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return PyBool_FromLong(((_PyExecutorObject *)self)->vm_data.valid); +} + +static PyMethodDef executor_methods[] = { + { "is_valid", is_valid, METH_NOARGS, NULL }, + { NULL, NULL }, }; static PyTypeObject CounterExecutor_Type = { @@ -237,7 +243,7 @@ static PyTypeObject CounterExecutor_Type = { .tp_itemsize = 0, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION, .tp_dealloc = (destructor)counter_dealloc, - .tp_members = counter_members, + .tp_methods = executor_methods, }; static _PyInterpreterFrame * @@ -280,7 +286,7 @@ counter_get_counter(PyObject *self, PyObject *args) return PyLong_FromLongLong(((_PyCounterOptimizerObject *)self)->count); } -static PyMethodDef counter_methods[] = { +static PyMethodDef counter_optimizer_methods[] = { { "get_count", counter_get_counter, METH_NOARGS, NULL }, { NULL, NULL }, }; @@ -291,7 +297,7 @@ static PyTypeObject CounterOptimizer_Type = { .tp_basicsize = sizeof(_PyCounterOptimizerObject), .tp_itemsize = 0, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION, - .tp_methods = counter_methods, + .tp_methods = counter_optimizer_methods, .tp_dealloc = (destructor)PyObject_Del, }; @@ -369,12 +375,6 @@ PySequenceMethods uop_as_sequence = { .sq_item = (ssizeargfunc)uop_item, }; - -static PyMemberDef uop_members[] = { - { "valid", Py_T_UBYTE, offsetof(_PyUOpExecutorObject, base.vm_data.valid), Py_READONLY, "is valid?" }, - { NULL } -}; - static PyTypeObject UOpExecutor_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "uop_executor", @@ -383,7 +383,7 @@ static PyTypeObject UOpExecutor_Type = { .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION, .tp_dealloc = (destructor)uop_dealloc, .tp_as_sequence = &uop_as_sequence, - .tp_members = uop_members, + .tp_methods = executor_methods, }; static int |