Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Doc/c-api/file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,22 @@ the :mod:`io` APIs instead.

Write string *s* to file object *p*. Return ``0`` on success or ``-1`` on
failure; the appropriate exception will be set.


Deprecated API
^^^^^^^^^^^^^^


These are :term:`soft deprecated` APIs that were included in Python's C API
by mistake. They are documented solely for completeness; use other
``PyFile*`` APIs instead.

.. c:function:: PyObject *PyFile_NewStdPrinter(int fd)

Use :c:func:`PyFile_FromFd` with defaults (``fd, NULL, "w", -1, NULL, NULL, NULL, 0``) instead.

.. c:var:: PyTypeObject PyStdPrinter_Type

Type of file-like objects used internally at Python startup when :py:mod:`io` is
not yet available.
Use Python :py:func:`open` or :c:func:`PyFile_FromFd` to create file objects instead.
12 changes: 12 additions & 0 deletions Doc/c-api/gen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ than explicitly calling :c:func:`PyGen_New` or :c:func:`PyGen_NewWithQualName`.
A reference to *frame* is stolen by this function. The *frame* argument
must not be ``NULL``.


.. c:function:: PyCodeObject* PyGen_GetCode(PyGenObject *gen)

Return a new :term:`strong reference` to the code object wrapped by *gen*.
Expand Down Expand Up @@ -82,3 +83,14 @@ Asynchronous Generator Objects
This function always succeeds.

.. versionadded:: 3.6


Deprecated API
^^^^^^^^^^^^^^

.. c:macro:: PyAsyncGenASend_CheckExact(op)

This is a :term:`soft deprecated` API that was included in Python's C API
by mistake.

It is solely here for completeness; do not use this API.
28 changes: 28 additions & 0 deletions Doc/c-api/long.rst
Original file line number Diff line number Diff line change
Expand Up @@ -855,3 +855,31 @@ The :c:type:`PyLongWriter` API can be used to import an integer.
If *writer* is ``NULL``, no operation is performed.

The writer instance and the *digits* array are invalid after the call.


Deprecated API
^^^^^^^^^^^^^^

These macros are :term:`soft deprecated`. They describe parameters
of the internal representation of :c:type:`PyLongObject` instances.

Use :c:func:`PyLong_GetNativeLayout` instead, along with :c:func:`PyLong_Export`
to read integer data or :c:type:`PyLongWriter` to write it.
These currently use the same layout, but are designed to continue working correctly
even if CPython's internal integer representation changes.


.. c:macro:: PyLong_SHIFT

This is equivalent to :c:member:`~PyLongLayout.bits_per_digit` in
the output of :c:func:`PyLong_GetNativeLayout`.


.. c:macro:: PyLong_BASE

This is currently equivalent to :c:expr:`1 << PyLong_SHIFT`.


.. c:macro:: PyLong_MASK

This is currently equivalent to :c:expr:`(1 << PyLong_SHIFT) - 1`
17 changes: 17 additions & 0 deletions Doc/c-api/set.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,20 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
Empty an existing set of all elements. Return ``0`` on
success. Return ``-1`` and raise :exc:`SystemError` if *set* is not an instance of
:class:`set` or its subtype.


Deprecated API
^^^^^^^^^^^^^^

.. c:macro:: PySet_MINSIZE

A :term:`soft deprecated` constant representing the size of an internal
preallocated table inside :c:type:`PySetObject` instances.

This is documented solely for completeness, as there are no guarantees
that a given version of CPython uses preallocated tables with a fixed
size.
In code that does not deal with unstable set internals,
:c:macro:`!PySet_MINSIZE` can be replaced with a small constant like ``8``.

If looking for the size of a set, use :c:func:`PySet_Size` instead.
10 changes: 0 additions & 10 deletions Tools/check-c-api-docs/ignored_c_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,11 @@ PyDescr_NAME
PyDescr_TYPE
PyWrapperFlag_KEYWORDS
# cpython/fileobject.h
PyFile_NewStdPrinter
PyStdPrinter_Type
Py_UniversalNewlineFgets
# cpython/setobject.h
PySet_MINSIZE
# cpython/ceval.h
PyUnstable_CopyPerfMapFile
PyUnstable_PerfTrampoline_CompileCode
PyUnstable_PerfTrampoline_SetPersistAfterFork
# cpython/genobject.h
PyAsyncGenASend_CheckExact
# cpython/longintrepr.h
PyLong_BASE
PyLong_MASK
PyLong_SHIFT
# cpython/pyerrors.h
PyException_HEAD
# cpython/pyframe.h
Expand Down
Loading