Clean up after bpo-33738. (GH-7627) · python/cpython@5cbefa9

File tree

4 files changed

lines changed

  • Misc/NEWS.d/next/Core and Builtins

4 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -593,12 +593,11 @@ PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *);

593593

/* Returns 1 if the object 'obj' provides iterator protocols, and 0 otherwise.

594594
595595

This function always succeeds. */

596+

PyAPI_FUNC(int) PyIter_Check(PyObject *);

596597

#ifndef Py_LIMITED_API

597598

#define PyIter_Check(obj) \

598599

((obj)->ob_type->tp_iternext != NULL && \

599600

(obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented)

600-

#else

601-

PyAPI_FUNC(int) PyIter_Check(PyObject *);

602601

#endif

603602
604603

/* Takes an iterator object and calls its tp_iternext slot,

@@ -719,12 +718,11 @@ PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2);

719718
720719

/* Returns 1 if obj is an index integer (has the nb_index slot of the

721720

tp_as_number structure filled in), and 0 otherwise. */

721+

PyAPI_FUNC(int) PyIndex_Check(PyObject *);

722722

#ifndef Py_LIMITED_API

723723

#define PyIndex_Check(obj) \

724724

((obj)->ob_type->tp_as_number != NULL && \

725725

(obj)->ob_type->tp_as_number->nb_index != NULL)

726-

#else

727-

PyAPI_FUNC(int) PyIndex_Check(PyObject *);

728726

#endif

729727
730728

/* Returns the object 'o' converted to a Python int, or NULL with an exception

Original file line numberDiff line numberDiff line change

@@ -140,11 +140,10 @@ PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);

140140

#define PyExceptionInstance_Check(x) \

141141

PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS)

142142
143+

PyAPI_FUNC(char *) PyExceptionClass_Name(PyObject *);

143144

#ifndef Py_LIMITED_API

144145

#define PyExceptionClass_Name(x) \

145146

((char *)(((PyTypeObject *)(x))->tp_name))

146-

#else

147-

PyAPI_FUNC(const char *) PyExceptionClass_Name(PyObject *);

148147

#endif

149148
150149

#define PyExceptionInstance_Class(x) ((PyObject*)((x)->ob_type))

Original file line numberDiff line numberDiff line change

@@ -1,4 +1,4 @@

11

Seven macro incompatibilities with the Limited API were fixed, and the

2-

macros PyIter_Check, PyIndex_Check and PyExceptionClass_Name were added as

3-

functions. The return type of PyExceptionClass_Name is "const char \*".

2+

macros :c:func:`PyIter_Check`, :c:func:`PyIndex_Check` and

3+

:c:func:`PyExceptionClass_Name` were added as functions.

44

A script for automatic macro checks was added.

Original file line numberDiff line numberDiff line change

@@ -347,7 +347,7 @@ PyException_SetContext(PyObject *self, PyObject *context)

347347

char *

348348

PyExceptionClass_Name(PyObject *ob)

349349

{

350-

return ((PyTypeObject*)ob)->tp_name;

350+

return (char *)((PyTypeObject*)ob)->tp_name;

351351

}

352352
353353

static struct PyMemberDef BaseException_members[] = {