[Python-checkins] Clean up after bpo-33738. (GH-7627)

Serhiy Storchaka webhook-mailer at python.org
Mon Jun 11 08:01:51 EDT 2018


https://github.com/python/cpython/commit/5cbefa99198729a1d4e93d93f890c066039ee1d2
commit: 5cbefa99198729a1d4e93d93f890c066039ee1d2
branch: master
author: Serhiy Storchaka <storchaka at gmail.com>
committer: GitHub <noreply at github.com>
date: 2018-06-11T15:01:47+03:00
summary:

Clean up after bpo-33738. (GH-7627)

* Add declarations even if they are overridden by macros.
* Make the declaration and the definition of PyExceptionClass_Name
  consistent.

files:
M Include/abstract.h
M Include/pyerrors.h
M Misc/NEWS.d/next/Core and Builtins/2018-06-07-18-34-19.bpo-33738.ODZS7a.rst
M Objects/exceptions.c

diff --git a/Include/abstract.h b/Include/abstract.h
index c1297dbedeab..85550a34ca26 100644
--- a/Include/abstract.h
+++ b/Include/abstract.h
@@ -593,12 +593,11 @@ PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *);
 /* Returns 1 if the object 'obj' provides iterator protocols, and 0 otherwise.
 
    This function always succeeds. */
+PyAPI_FUNC(int) PyIter_Check(PyObject *);
 #ifndef Py_LIMITED_API
 #define PyIter_Check(obj) \
     ((obj)->ob_type->tp_iternext != NULL && \
      (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented)
-#else
-PyAPI_FUNC(int) PyIter_Check(PyObject *);
 #endif
 
 /* Takes an iterator object and calls its tp_iternext slot,
@@ -719,12 +718,11 @@ PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2);
 
 /* Returns 1 if obj is an index integer (has the nb_index slot of the
    tp_as_number structure filled in), and 0 otherwise. */
+PyAPI_FUNC(int) PyIndex_Check(PyObject *);
 #ifndef Py_LIMITED_API
 #define PyIndex_Check(obj)                              \
     ((obj)->ob_type->tp_as_number != NULL &&            \
      (obj)->ob_type->tp_as_number->nb_index != NULL)
-#else
-PyAPI_FUNC(int) PyIndex_Check(PyObject *);
 #endif
 
 /* Returns the object 'o' converted to a Python int, or NULL with an exception
diff --git a/Include/pyerrors.h b/Include/pyerrors.h
index 5fd981c2bae9..5b626584bb25 100644
--- a/Include/pyerrors.h
+++ b/Include/pyerrors.h
@@ -140,11 +140,10 @@ PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
 #define PyExceptionInstance_Check(x)                    \
     PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS)
 
+PyAPI_FUNC(char *) PyExceptionClass_Name(PyObject *);
 #ifndef Py_LIMITED_API
 #define PyExceptionClass_Name(x) \
      ((char *)(((PyTypeObject *)(x))->tp_name))
-#else
-     PyAPI_FUNC(const char *) PyExceptionClass_Name(PyObject *);
 #endif
 
 #define PyExceptionInstance_Class(x) ((PyObject*)((x)->ob_type))
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-06-07-18-34-19.bpo-33738.ODZS7a.rst b/Misc/NEWS.d/next/Core and Builtins/2018-06-07-18-34-19.bpo-33738.ODZS7a.rst
index 0b7365d05a5f..2e0c43c62256 100644
--- a/Misc/NEWS.d/next/Core and Builtins/2018-06-07-18-34-19.bpo-33738.ODZS7a.rst	
+++ b/Misc/NEWS.d/next/Core and Builtins/2018-06-07-18-34-19.bpo-33738.ODZS7a.rst	
@@ -1,4 +1,4 @@
 Seven macro incompatibilities with the Limited API were fixed, and the
-macros PyIter_Check, PyIndex_Check and PyExceptionClass_Name were added as
-functions. The return type of PyExceptionClass_Name is "const char \*".
+macros :c:func:`PyIter_Check`, :c:func:`PyIndex_Check` and
+:c:func:`PyExceptionClass_Name` were added as functions.
 A script for automatic macro checks was added.
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 7beb2a2891de..e1615b2a8f3a 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -347,7 +347,7 @@ PyException_SetContext(PyObject *self, PyObject *context)
 char *
 PyExceptionClass_Name(PyObject *ob)
 {
-    return ((PyTypeObject*)ob)->tp_name;
+    return (char *)((PyTypeObject*)ob)->tp_name;
 }
 
 static struct PyMemberDef BaseException_members[] = {



More information about the Python-checkins mailing list