mirror of https://github.com/python/cpython
Rename _PyIter_GetBuiltin to _PyObject_GetBuiltin, and do not include it in the stable ABI.
This commit is contained in:
parent
d4dc6dc9e7
commit
a701388de1
|
@ -18,8 +18,6 @@ PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *);
|
PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *);
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject *) _PyIter_GetBuiltin(const char *iter);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -535,6 +535,11 @@ PyAPI_FUNC(int)
|
||||||
_PyObject_GenericSetAttrWithDict(PyObject *, PyObject *,
|
_PyObject_GenericSetAttrWithDict(PyObject *, PyObject *,
|
||||||
PyObject *, PyObject *);
|
PyObject *, PyObject *);
|
||||||
|
|
||||||
|
/* Helper to look up a builtin object */
|
||||||
|
#ifndef Py_LIMITED_API
|
||||||
|
PyAPI_FUNC(PyObject *)
|
||||||
|
_PyObject_GetBuiltin(const char *name);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* PyObject_Dir(obj) acts like Python builtins.dir(obj), returning a
|
/* PyObject_Dir(obj) acts like Python builtins.dir(obj), returning a
|
||||||
list of strings. PyObject_Dir(NULL) is like builtins.dir(),
|
list of strings. PyObject_Dir(NULL) is like builtins.dir(),
|
||||||
|
|
|
@ -2756,7 +2756,7 @@ arrayiter_traverse(arrayiterobject *it, visitproc visit, void *arg)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
arrayiter_reduce(arrayiterobject *it)
|
arrayiter_reduce(arrayiterobject *it)
|
||||||
{
|
{
|
||||||
return Py_BuildValue("N(O)n", _PyIter_GetBuiltin("iter"),
|
return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("iter"),
|
||||||
it->ao, it->index);
|
it->ao, it->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3018,13 +3018,13 @@ static PyObject *
|
||||||
bytearrayiter_reduce(bytesiterobject *it)
|
bytearrayiter_reduce(bytesiterobject *it)
|
||||||
{
|
{
|
||||||
if (it->it_seq != NULL) {
|
if (it->it_seq != NULL) {
|
||||||
return Py_BuildValue("N(O)n", _PyIter_GetBuiltin("iter"),
|
return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("iter"),
|
||||||
it->it_seq, it->it_index);
|
it->it_seq, it->it_index);
|
||||||
} else {
|
} else {
|
||||||
PyObject *u = PyUnicode_FromUnicode(NULL, 0);
|
PyObject *u = PyUnicode_FromUnicode(NULL, 0);
|
||||||
if (u == NULL)
|
if (u == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return Py_BuildValue("N(N)", _PyIter_GetBuiltin("iter"), u);
|
return Py_BuildValue("N(N)", _PyObject_GetBuiltin("iter"), u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3078,13 +3078,13 @@ static PyObject *
|
||||||
striter_reduce(striterobject *it)
|
striter_reduce(striterobject *it)
|
||||||
{
|
{
|
||||||
if (it->it_seq != NULL) {
|
if (it->it_seq != NULL) {
|
||||||
return Py_BuildValue("N(O)n", _PyIter_GetBuiltin("iter"),
|
return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("iter"),
|
||||||
it->it_seq, it->it_index);
|
it->it_seq, it->it_index);
|
||||||
} else {
|
} else {
|
||||||
PyObject *u = PyUnicode_FromUnicode(NULL, 0);
|
PyObject *u = PyUnicode_FromUnicode(NULL, 0);
|
||||||
if (u == NULL)
|
if (u == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return Py_BuildValue("N(N)", _PyIter_GetBuiltin("iter"), u);
|
return Py_BuildValue("N(N)", _PyObject_GetBuiltin("iter"), u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2610,7 +2610,7 @@ dictiter_reduce(dictiterobject *di)
|
||||||
Py_DECREF(list);
|
Py_DECREF(list);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return Py_BuildValue("N(N)", _PyIter_GetBuiltin("iter"), list);
|
return Py_BuildValue("N(N)", _PyObject_GetBuiltin("iter"), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
|
|
|
@ -2,19 +2,6 @@
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
|
||||||
/* Convenience function to get builtins.iter or builtins.reversed */
|
|
||||||
PyObject *
|
|
||||||
_PyIter_GetBuiltin(const char *iter)
|
|
||||||
{
|
|
||||||
PyObject *mod, *attr;
|
|
||||||
mod = PyImport_ImportModule("builtins");
|
|
||||||
if (mod == NULL)
|
|
||||||
return NULL;
|
|
||||||
attr = PyObject_GetAttrString(mod, iter);
|
|
||||||
Py_DECREF(mod);
|
|
||||||
return attr;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
long it_index;
|
long it_index;
|
||||||
|
@ -105,10 +92,10 @@ static PyObject *
|
||||||
iter_reduce(seqiterobject *it)
|
iter_reduce(seqiterobject *it)
|
||||||
{
|
{
|
||||||
if (it->it_seq != NULL)
|
if (it->it_seq != NULL)
|
||||||
return Py_BuildValue("N(O)n", _PyIter_GetBuiltin("iter"),
|
return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("iter"),
|
||||||
it->it_seq, it->it_index);
|
it->it_seq, it->it_index);
|
||||||
else
|
else
|
||||||
return Py_BuildValue("N(())", _PyIter_GetBuiltin("iter"));
|
return Py_BuildValue("N(())", _PyObject_GetBuiltin("iter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
|
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
|
||||||
|
@ -242,10 +229,10 @@ static PyObject *
|
||||||
calliter_reduce(calliterobject *it)
|
calliter_reduce(calliterobject *it)
|
||||||
{
|
{
|
||||||
if (it->it_callable != NULL && it->it_sentinel != NULL)
|
if (it->it_callable != NULL && it->it_sentinel != NULL)
|
||||||
return Py_BuildValue("N(OO)", _PyIter_GetBuiltin("iter"),
|
return Py_BuildValue("N(OO)", _PyObject_GetBuiltin("iter"),
|
||||||
it->it_callable, it->it_sentinel);
|
it->it_callable, it->it_sentinel);
|
||||||
else
|
else
|
||||||
return Py_BuildValue("N(())", _PyIter_GetBuiltin("iter"));
|
return Py_BuildValue("N(())", _PyObject_GetBuiltin("iter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef calliter_methods[] = {
|
static PyMethodDef calliter_methods[] = {
|
||||||
|
|
|
@ -2949,17 +2949,17 @@ listiter_reduce_general(void *_it, int forward)
|
||||||
if (forward) {
|
if (forward) {
|
||||||
listiterobject *it = (listiterobject *)_it;
|
listiterobject *it = (listiterobject *)_it;
|
||||||
if (it->it_seq)
|
if (it->it_seq)
|
||||||
return Py_BuildValue("N(O)l", _PyIter_GetBuiltin("iter"),
|
return Py_BuildValue("N(O)l", _PyObject_GetBuiltin("iter"),
|
||||||
it->it_seq, it->it_index);
|
it->it_seq, it->it_index);
|
||||||
} else {
|
} else {
|
||||||
listreviterobject *it = (listreviterobject *)_it;
|
listreviterobject *it = (listreviterobject *)_it;
|
||||||
if (it->it_seq)
|
if (it->it_seq)
|
||||||
return Py_BuildValue("N(O)n", _PyIter_GetBuiltin("reversed"),
|
return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("reversed"),
|
||||||
it->it_seq, it->it_index);
|
it->it_seq, it->it_index);
|
||||||
}
|
}
|
||||||
/* empty iterator, create an empty list */
|
/* empty iterator, create an empty list */
|
||||||
list = PyList_New(0);
|
list = PyList_New(0);
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return Py_BuildValue("N(N)", _PyIter_GetBuiltin("iter"), list);
|
return Py_BuildValue("N(N)", _PyObject_GetBuiltin("iter"), list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1026,6 +1026,19 @@ PyObject_SelfIter(PyObject *obj)
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Convenience function to get a builtin from its name */
|
||||||
|
PyObject *
|
||||||
|
_PyObject_GetBuiltin(const char *name)
|
||||||
|
{
|
||||||
|
PyObject *mod, *attr;
|
||||||
|
mod = PyImport_ImportModule("builtins");
|
||||||
|
if (mod == NULL)
|
||||||
|
return NULL;
|
||||||
|
attr = PyObject_GetAttrString(mod, name);
|
||||||
|
Py_DECREF(mod);
|
||||||
|
return attr;
|
||||||
|
}
|
||||||
|
|
||||||
/* Helper used when the __next__ method is removed from a type:
|
/* Helper used when the __next__ method is removed from a type:
|
||||||
tp_iternext is never NULL and can be safely called without checking
|
tp_iternext is never NULL and can be safely called without checking
|
||||||
on every iteration.
|
on every iteration.
|
||||||
|
|
|
@ -985,7 +985,7 @@ rangeiter_reduce(rangeiterobject *r)
|
||||||
if (range == NULL)
|
if (range == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
/* return the result */
|
/* return the result */
|
||||||
return Py_BuildValue("N(N)i", _PyIter_GetBuiltin("iter"), range, r->index);
|
return Py_BuildValue("N(N)i", _PyObject_GetBuiltin("iter"), range, r->index);
|
||||||
err:
|
err:
|
||||||
Py_XDECREF(start);
|
Py_XDECREF(start);
|
||||||
Py_XDECREF(stop);
|
Py_XDECREF(stop);
|
||||||
|
@ -1171,7 +1171,7 @@ longrangeiter_reduce(longrangeiterobject *r)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return the result */
|
/* return the result */
|
||||||
return Py_BuildValue("N(N)O", _PyIter_GetBuiltin("iter"), range, r->index);
|
return Py_BuildValue("N(N)O", _PyObject_GetBuiltin("iter"), range, r->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
@ -856,7 +856,7 @@ setiter_reduce(setiterobject *si)
|
||||||
Py_DECREF(list);
|
Py_DECREF(list);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return Py_BuildValue("N(N)", _PyIter_GetBuiltin("iter"), list);
|
return Py_BuildValue("N(N)", _PyObject_GetBuiltin("iter"), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
|
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
|
||||||
|
|
|
@ -971,10 +971,10 @@ static PyObject *
|
||||||
tupleiter_reduce(tupleiterobject *it)
|
tupleiter_reduce(tupleiterobject *it)
|
||||||
{
|
{
|
||||||
if (it->it_seq)
|
if (it->it_seq)
|
||||||
return Py_BuildValue("N(O)l", _PyIter_GetBuiltin("iter"),
|
return Py_BuildValue("N(O)l", _PyObject_GetBuiltin("iter"),
|
||||||
it->it_seq, it->it_index);
|
it->it_seq, it->it_index);
|
||||||
else
|
else
|
||||||
return Py_BuildValue("N(())", _PyIter_GetBuiltin("iter"));
|
return Py_BuildValue("N(())", _PyObject_GetBuiltin("iter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
@ -14386,13 +14386,13 @@ static PyObject *
|
||||||
unicodeiter_reduce(unicodeiterobject *it)
|
unicodeiter_reduce(unicodeiterobject *it)
|
||||||
{
|
{
|
||||||
if (it->it_seq != NULL) {
|
if (it->it_seq != NULL) {
|
||||||
return Py_BuildValue("N(O)n", _PyIter_GetBuiltin("iter"),
|
return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("iter"),
|
||||||
it->it_seq, it->it_index);
|
it->it_seq, it->it_index);
|
||||||
} else {
|
} else {
|
||||||
PyObject *u = PyUnicode_FromUnicode(NULL, 0);
|
PyObject *u = PyUnicode_FromUnicode(NULL, 0);
|
||||||
if (u == NULL)
|
if (u == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return Py_BuildValue("N(N)", _PyIter_GetBuiltin("iter"), u);
|
return Py_BuildValue("N(N)", _PyObject_GetBuiltin("iter"), u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue