Skip to content

Commit 09ecaef

Browse files
committed
Declare tp_iteritem and iteritemfunc private by adding _ prefix to names
1 parent 1c269b6 commit 09ecaef

File tree

16 files changed

+33
-44
lines changed

16 files changed

+33
-44
lines changed

Doc/c-api/typeobj.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ Quick Reference
147147
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
148148
| :c:member:`~PyTypeObject.tp_vectorcall` | :c:type:`vectorcallfunc` | | | | | |
149149
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
150-
| [:c:member:`~PyTypeObject.tp_iteritem`] | opaque function pointer | | | | | |
151-
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
152150
| [:c:member:`~PyTypeObject.tp_watched`] | unsigned char | | | | | |
153151
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
154152

@@ -2552,13 +2550,6 @@ and :c:data:`PyType_Type` effectively act as defaults.)
25522550
.. versionadded:: 3.12
25532551

25542552

2555-
.. c:member:: function_pointer PyTypeObject.tp_iteritem
2556-
2557-
Internal. Do not use.
2558-
2559-
.. versionadded:: 3.15
2560-
2561-
25622553
.. _static-types:
25632554

25642555
Static Types

Doc/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@
179179
('c:type', 'unsigned __int64'),
180180
('c:type', 'double'),
181181
('c:type', '_Float16'),
182-
# Opaque C types
183-
('c:type', 'function_pointer'),
184182
# Standard C structures
185183
('c:struct', 'in6_addr'),
186184
('c:struct', 'in_addr'),

Include/cpython/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ struct _typeobject {
241241
* Otherwise, limited to MAX_VERSIONS_PER_CLASS (defined elsewhere).
242242
*/
243243
uint16_t tp_versions_used;
244-
iteritemfunc tp_iteritem; /* Virtual iterator next function */
244+
_Py_iteritemfunc _tp_iteritem; /* Virtual iterator next function */
245245
};
246246

247247
#define _Py_ATTR_CACHE_UNUSED (30000) // (see tp_versions_used)

Include/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ typedef struct _py_object_index_pair {
310310
PyObject *object;
311311
Py_ssize_t index;
312312
} _PyObjectIndexPair;
313-
typedef _PyObjectIndexPair (*iteritemfunc) (PyObject *, Py_ssize_t index);
313+
typedef _PyObjectIndexPair (*_Py_iteritemfunc) (PyObject *, Py_ssize_t index);
314314
typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *);
315315
typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *);
316316
typedef int (*initproc)(PyObject *, PyObject *, PyObject *);

Modules/_testinternalcapi/test_cases.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/bytesobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3260,7 +3260,7 @@ PyTypeObject PyBytes_Type = {
32603260
bytes_new, /* tp_new */
32613261
PyObject_Free, /* tp_free */
32623262
.tp_version_tag = _Py_TYPE_VERSION_BYTES,
3263-
.tp_iteritem = bytes_iteritem,
3263+
._tp_iteritem = bytes_iteritem,
32643264
};
32653265

32663266
void

Objects/listobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3970,7 +3970,7 @@ PyTypeObject PyList_Type = {
39703970
PyObject_GC_Del, /* tp_free */
39713971
.tp_vectorcall = list_vectorcall,
39723972
.tp_version_tag = _Py_TYPE_VERSION_LIST,
3973-
.tp_iteritem = list_iteritem,
3973+
._tp_iteritem = list_iteritem,
39743974
};
39753975

39763976
/*********************** List Iterator **************************/

Objects/tupleobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ PyTypeObject PyTuple_Type = {
10111011
PyObject_GC_Del, /* tp_free */
10121012
.tp_vectorcall = tuple_vectorcall,
10131013
.tp_version_tag = _Py_TYPE_VERSION_TUPLE,
1014-
.tp_iteritem = tuple_iteritem,
1014+
._tp_iteritem = tuple_iteritem,
10151015
};
10161016

10171017
/* The following function breaks the notion that tuples are immutable:

Objects/unicodeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14061,7 +14061,7 @@ PyTypeObject PyUnicode_Type = {
1406114061
unicode_new, /* tp_new */
1406214062
PyObject_Free, /* tp_free */
1406314063
.tp_vectorcall = unicode_vectorcall,
14064-
.tp_iteritem = unicode_iteritem,
14064+
._tp_iteritem = unicode_iteritem,
1406514065
};
1406614066

1406714067
/* Initialize the Unicode implementation */

Python/bytecodes.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3634,7 +3634,7 @@ dummy_func(
36343634

36353635
op(_GUARD_ITER_VIRTUAL, (iterable -- iterable)) {
36363636
PyTypeObject *tp = Py_TYPE(PyStackRef_AsPyObjectBorrow(iterable));
3637-
EXIT_IF(tp->tp_iteritem == NULL);
3637+
EXIT_IF(tp->_tp_iteritem == NULL);
36383638
STAT_INC(GET_ITER, hit);
36393639
}
36403640

@@ -3712,13 +3712,13 @@ dummy_func(
37123712

37133713
op(_GUARD_NOS_ITER_VIRTUAL, (iter, null_or_index -- iter, null_or_index)) {
37143714
PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter);
3715-
EXIT_IF(Py_TYPE(iter_o)->tp_iteritem == NULL);
3715+
EXIT_IF(Py_TYPE(iter_o)->_tp_iteritem == NULL);
37163716
}
37173717

37183718
replaced op(_FOR_ITER_VIRTUAL, (iter, null_or_index -- iter, null_or_index, next)) {
37193719
PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter);
37203720
Py_ssize_t index = PyStackRef_UntagInt(null_or_index);
3721-
_PyObjectIndexPair next_index = Py_TYPE(iter_o)->tp_iteritem(iter_o, index);
3721+
_PyObjectIndexPair next_index = Py_TYPE(iter_o)->_tp_iteritem(iter_o, index);
37223722
PyObject *next_o = next_index.object;
37233723
index = next_index.index;
37243724
if (next_o == NULL) {
@@ -3741,7 +3741,7 @@ dummy_func(
37413741
op(_FOR_ITER_VIRTUAL_TIER_TWO, (iter, null_or_index -- iter, null_or_index, next)) {
37423742
PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter);
37433743
Py_ssize_t index = PyStackRef_UntagInt(null_or_index);
3744-
_PyObjectIndexPair next_index = Py_TYPE(iter_o)->tp_iteritem(iter_o, index);
3744+
_PyObjectIndexPair next_index = Py_TYPE(iter_o)->_tp_iteritem(iter_o, index);
37453745
PyObject *next_o = next_index.object;
37463746
index = next_index.index;
37473747
if (next_o == NULL) {

0 commit comments

Comments
 (0)