bpo-45474: Exclude all of marshal.h if Py_LIMITED_API is defined (GH-29061)

Also, reword the What's New messages: this doesn't change the limited API, it only brings the Py_LIMITED_API macro closer to the ideal of only allowing the limited API.

Automerge-Triggered-By: GH:encukou
This commit is contained in:
Petr Viktorin 2021-10-20 11:32:14 +02:00 committed by GitHub
parent 085ccb0f17
commit 98fa3b53e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 9 deletions

View File

@ -627,14 +627,17 @@ Removed
``Py_IS_INFINITY()`` macro. ``Py_IS_INFINITY()`` macro.
(Contributed by Victor Stinner in :issue:`45440`.) (Contributed by Victor Stinner in :issue:`45440`.)
* Remove two functions from the limited C API: * The following items are no longer available when :c:macro:`Py_LIMITED_API`
is defined:
* :c:func:`PyMarshal_WriteLongToFile` * :c:func:`PyMarshal_WriteLongToFile`
* :c:func:`PyMarshal_WriteObjectToFile` * :c:func:`PyMarshal_WriteObjectToFile`
* :c:func:`PyMarshal_ReadObjectFromString`
* :c:func:`PyMarshal_WriteObjectToString`
* the ``Py_MARSHAL_VERSION`` macro
The :pep:`384` excludes functions expecting ``FILE*`` from the stable ABI. These are not part of the :ref:`limited API <stable-abi-list>`.
Remove also the ``Py_MARSHAL_VERSION`` macro from the limited C API.
(Contributed by Victor Stinner in :issue:`45474`.) (Contributed by Victor Stinner in :issue:`45474`.)
* Exclude :c:func:`PyWeakref_GET_OBJECT` from the limited C API. It never * Exclude :c:func:`PyWeakref_GET_OBJECT` from the limited C API. It never

View File

@ -3,6 +3,8 @@
#ifndef Py_MARSHAL_H #ifndef Py_MARSHAL_H
#define Py_MARSHAL_H #define Py_MARSHAL_H
#ifndef Py_LIMITED_API
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -11,7 +13,6 @@ PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(const char *,
Py_ssize_t); Py_ssize_t);
PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int); PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int);
#ifndef Py_LIMITED_API
#define Py_MARSHAL_VERSION 4 #define Py_MARSHAL_VERSION 4
PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *); PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
@ -21,9 +22,10 @@ PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int); PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int);
PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int); PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* Py_LIMITED_API */
#endif /* !Py_MARSHAL_H */ #endif /* !Py_MARSHAL_H */

View File

@ -1,10 +1,11 @@
Remove two functions from the limited C API: The following items are no longer available when ``Py_LIMITED_API`` is defined:
* :c:func:`PyMarshal_WriteLongToFile` * :c:func:`PyMarshal_WriteLongToFile`
* :c:func:`PyMarshal_WriteObjectToFile` * :c:func:`PyMarshal_WriteObjectToFile`
* :c:func:`PyMarshal_ReadObjectFromString`
* :c:func:`PyMarshal_WriteObjectToString`
* the ``Py_MARSHAL_VERSION`` macro
The :pep:`384` excludes functions expecting ``FILE*`` from the stable ABI. These are not part of the :ref:`limited API <stable-abi-list>`.
Remove also the ``Py_MARSHAL_VERSION`` macro from the limited C API.
Patch by Victor Stinner. Patch by Victor Stinner.