mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-111178: Fix function signatures of unicodeiter (#130684)
This commit is contained in:
parent
15d926b285
commit
ed8675c571
1 changed files with 23 additions and 19 deletions
|
@ -16025,23 +16025,26 @@ typedef struct {
|
||||||
} unicodeiterobject;
|
} unicodeiterobject;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unicodeiter_dealloc(unicodeiterobject *it)
|
unicodeiter_dealloc(PyObject *op)
|
||||||
{
|
{
|
||||||
|
unicodeiterobject *it = (unicodeiterobject *)op;
|
||||||
_PyObject_GC_UNTRACK(it);
|
_PyObject_GC_UNTRACK(it);
|
||||||
Py_XDECREF(it->it_seq);
|
Py_XDECREF(it->it_seq);
|
||||||
PyObject_GC_Del(it);
|
PyObject_GC_Del(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unicodeiter_traverse(unicodeiterobject *it, visitproc visit, void *arg)
|
unicodeiter_traverse(PyObject *op, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
|
unicodeiterobject *it = (unicodeiterobject *)op;
|
||||||
Py_VISIT(it->it_seq);
|
Py_VISIT(it->it_seq);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
unicodeiter_next(unicodeiterobject *it)
|
unicodeiter_next(PyObject *op)
|
||||||
{
|
{
|
||||||
|
unicodeiterobject *it = (unicodeiterobject *)op;
|
||||||
PyObject *seq;
|
PyObject *seq;
|
||||||
|
|
||||||
assert(it != NULL);
|
assert(it != NULL);
|
||||||
|
@ -16064,8 +16067,9 @@ unicodeiter_next(unicodeiterobject *it)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
unicode_ascii_iter_next(unicodeiterobject *it)
|
unicode_ascii_iter_next(PyObject *op)
|
||||||
{
|
{
|
||||||
|
unicodeiterobject *it = (unicodeiterobject *)op;
|
||||||
assert(it != NULL);
|
assert(it != NULL);
|
||||||
PyObject *seq = it->it_seq;
|
PyObject *seq = it->it_seq;
|
||||||
if (seq == NULL) {
|
if (seq == NULL) {
|
||||||
|
@ -16086,8 +16090,9 @@ unicode_ascii_iter_next(unicodeiterobject *it)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
unicodeiter_len(unicodeiterobject *it, PyObject *Py_UNUSED(ignored))
|
unicodeiter_len(PyObject *op, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
|
unicodeiterobject *it = (unicodeiterobject *)op;
|
||||||
Py_ssize_t len = 0;
|
Py_ssize_t len = 0;
|
||||||
if (it->it_seq)
|
if (it->it_seq)
|
||||||
len = PyUnicode_GET_LENGTH(it->it_seq) - it->it_index;
|
len = PyUnicode_GET_LENGTH(it->it_seq) - it->it_index;
|
||||||
|
@ -16097,8 +16102,9 @@ unicodeiter_len(unicodeiterobject *it, PyObject *Py_UNUSED(ignored))
|
||||||
PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it)).");
|
PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it)).");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
unicodeiter_reduce(unicodeiterobject *it, PyObject *Py_UNUSED(ignored))
|
unicodeiter_reduce(PyObject *op, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
|
unicodeiterobject *it = (unicodeiterobject *)op;
|
||||||
PyObject *iter = _PyEval_GetBuiltin(&_Py_ID(iter));
|
PyObject *iter = _PyEval_GetBuiltin(&_Py_ID(iter));
|
||||||
|
|
||||||
/* _PyEval_GetBuiltin can invoke arbitrary code,
|
/* _PyEval_GetBuiltin can invoke arbitrary code,
|
||||||
|
@ -16120,8 +16126,9 @@ unicodeiter_reduce(unicodeiterobject *it, PyObject *Py_UNUSED(ignored))
|
||||||
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
|
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
unicodeiter_setstate(unicodeiterobject *it, PyObject *state)
|
unicodeiter_setstate(PyObject *op, PyObject *state)
|
||||||
{
|
{
|
||||||
|
unicodeiterobject *it = (unicodeiterobject *)op;
|
||||||
Py_ssize_t index = PyLong_AsSsize_t(state);
|
Py_ssize_t index = PyLong_AsSsize_t(state);
|
||||||
if (index == -1 && PyErr_Occurred())
|
if (index == -1 && PyErr_Occurred())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -16138,12 +16145,9 @@ unicodeiter_setstate(unicodeiterobject *it, PyObject *state)
|
||||||
PyDoc_STRVAR(setstate_doc, "Set state information for unpickling.");
|
PyDoc_STRVAR(setstate_doc, "Set state information for unpickling.");
|
||||||
|
|
||||||
static PyMethodDef unicodeiter_methods[] = {
|
static PyMethodDef unicodeiter_methods[] = {
|
||||||
{"__length_hint__", (PyCFunction)unicodeiter_len, METH_NOARGS,
|
{"__length_hint__", unicodeiter_len, METH_NOARGS, length_hint_doc},
|
||||||
length_hint_doc},
|
{"__reduce__", unicodeiter_reduce, METH_NOARGS, reduce_doc},
|
||||||
{"__reduce__", (PyCFunction)unicodeiter_reduce, METH_NOARGS,
|
{"__setstate__", unicodeiter_setstate, METH_O, setstate_doc},
|
||||||
reduce_doc},
|
|
||||||
{"__setstate__", (PyCFunction)unicodeiter_setstate, METH_O,
|
|
||||||
setstate_doc},
|
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16153,7 +16157,7 @@ PyTypeObject PyUnicodeIter_Type = {
|
||||||
sizeof(unicodeiterobject), /* tp_basicsize */
|
sizeof(unicodeiterobject), /* tp_basicsize */
|
||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
(destructor)unicodeiter_dealloc, /* tp_dealloc */
|
unicodeiter_dealloc,/* tp_dealloc */
|
||||||
0, /* tp_vectorcall_offset */
|
0, /* tp_vectorcall_offset */
|
||||||
0, /* tp_getattr */
|
0, /* tp_getattr */
|
||||||
0, /* tp_setattr */
|
0, /* tp_setattr */
|
||||||
|
@ -16170,12 +16174,12 @@ PyTypeObject PyUnicodeIter_Type = {
|
||||||
0, /* tp_as_buffer */
|
0, /* tp_as_buffer */
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
|
||||||
0, /* tp_doc */
|
0, /* tp_doc */
|
||||||
(traverseproc)unicodeiter_traverse, /* tp_traverse */
|
unicodeiter_traverse, /* tp_traverse */
|
||||||
0, /* tp_clear */
|
0, /* tp_clear */
|
||||||
0, /* tp_richcompare */
|
0, /* tp_richcompare */
|
||||||
0, /* tp_weaklistoffset */
|
0, /* tp_weaklistoffset */
|
||||||
PyObject_SelfIter, /* tp_iter */
|
PyObject_SelfIter, /* tp_iter */
|
||||||
(iternextfunc)unicodeiter_next, /* tp_iternext */
|
unicodeiter_next, /* tp_iternext */
|
||||||
unicodeiter_methods, /* tp_methods */
|
unicodeiter_methods, /* tp_methods */
|
||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
|
@ -16184,12 +16188,12 @@ PyTypeObject _PyUnicodeASCIIIter_Type = {
|
||||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||||
.tp_name = "str_ascii_iterator",
|
.tp_name = "str_ascii_iterator",
|
||||||
.tp_basicsize = sizeof(unicodeiterobject),
|
.tp_basicsize = sizeof(unicodeiterobject),
|
||||||
.tp_dealloc = (destructor)unicodeiter_dealloc,
|
.tp_dealloc = unicodeiter_dealloc,
|
||||||
.tp_getattro = PyObject_GenericGetAttr,
|
.tp_getattro = PyObject_GenericGetAttr,
|
||||||
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
|
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
|
||||||
.tp_traverse = (traverseproc)unicodeiter_traverse,
|
.tp_traverse = unicodeiter_traverse,
|
||||||
.tp_iter = PyObject_SelfIter,
|
.tp_iter = PyObject_SelfIter,
|
||||||
.tp_iternext = (iternextfunc)unicode_ascii_iter_next,
|
.tp_iternext = unicode_ascii_iter_next,
|
||||||
.tp_methods = unicodeiter_methods,
|
.tp_methods = unicodeiter_methods,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue