Skip to content

Commit 5241130

Browse files
committed
Remove explicit __sizeof__() definition and add another size check in test_sys
1 parent 5a44669 commit 5241130

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

Lib/test/test_sys.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,8 +1640,10 @@ def bar(cls):
16401640
# classmethod
16411641
check(bar, size('PP'))
16421642
# generator
1643-
def get_gen(): yield 1
1644-
check(get_gen(), size('7P4c' + INTERPRETER_FRAME + 'P'))
1643+
def get_gen1(): yield
1644+
check(get_gen1(), size('7P4c' + INTERPRETER_FRAME + 'P'))
1645+
def get_gen2(): _ = yield
1646+
check(get_gen2(), size('7P4c' + INTERPRETER_FRAME + 'PP'))
16451647
# iterator
16461648
check(iter('abc'), size('lP'))
16471649
# callable-iterator

Objects/genobject.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -814,24 +814,10 @@ static PyMemberDef gen_memberlist[] = {
814814
{NULL} /* Sentinel */
815815
};
816816

817-
static PyObject *
818-
gen_sizeof(PyGenObject *gen, PyObject *Py_UNUSED(ignored))
819-
{
820-
Py_ssize_t res;
821-
res = offsetof(PyGenObject, gi_iframe) + offsetof(_PyInterpreterFrame, localsplus);
822-
PyCodeObject *code = _PyGen_GetCode(gen);
823-
res += _PyFrame_NumSlotsForCodeObject(code) * sizeof(PyObject *);
824-
return PyLong_FromSsize_t(res);
825-
}
826-
827-
PyDoc_STRVAR(sizeof__doc__,
828-
"gen.__sizeof__() -> size of gen in memory, in bytes");
829-
830817
static PyMethodDef gen_methods[] = {
831818
{"send", gen_send, METH_O, send_doc},
832819
{"throw", _PyCFunction_CAST(gen_throw), METH_FASTCALL, throw_doc},
833820
{"close", gen_close, METH_NOARGS, close_doc},
834-
{"__sizeof__", (PyCFunction)gen_sizeof, METH_NOARGS, sizeof__doc__},
835821
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
836822
{NULL, NULL} /* Sentinel */
837823
};
@@ -1192,7 +1178,6 @@ static PyMethodDef coro_methods[] = {
11921178
{"send", gen_send, METH_O, coro_send_doc},
11931179
{"throw",_PyCFunction_CAST(gen_throw), METH_FASTCALL, coro_throw_doc},
11941180
{"close", gen_close, METH_NOARGS, coro_close_doc},
1195-
{"__sizeof__", (PyCFunction)gen_sizeof, METH_NOARGS, sizeof__doc__},
11961181
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
11971182
{NULL, NULL} /* Sentinel */
11981183
};
@@ -1620,7 +1605,6 @@ static PyMethodDef async_gen_methods[] = {
16201605
{"asend", (PyCFunction)async_gen_asend, METH_O, async_asend_doc},
16211606
{"athrow",(PyCFunction)async_gen_athrow, METH_VARARGS, async_athrow_doc},
16221607
{"aclose", (PyCFunction)async_gen_aclose, METH_NOARGS, async_aclose_doc},
1623-
{"__sizeof__", (PyCFunction)gen_sizeof, METH_NOARGS, sizeof__doc__},
16241608
{"__class_getitem__", Py_GenericAlias,
16251609
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
16261610
{NULL, NULL} /* Sentinel */

0 commit comments

Comments
 (0)