Skip to content
Merged
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
4 changes: 4 additions & 0 deletions Doc/c-api/buffer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ readonly, format
MUST be consistent for all consumers. For example, :c:expr:`PyBUF_SIMPLE | PyBUF_WRITABLE`
can be used to request a simple writable buffer.

.. c:macro:: PyBUF_WRITEABLE

This is a :term:`soft deprecated` alias to :c:macro:`PyBUF_WRITABLE`.

.. c:macro:: PyBUF_FORMAT

Controls the :c:member:`~Py_buffer.format` field. If set, this field MUST
Expand Down
17 changes: 17 additions & 0 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,23 @@ For convenience, some of these functions will always return a
use.


.. c:function:: PyObject *PyErr_ProgramTextObject(PyObject *filename, int lineno)

Get the source line in *filename* at line *lineno*. *filename* should be a
Python :class:`str` object.

On success, this function returns a Python string object with the found line.
On failure, this function returns ``NULL`` without an exception set.


.. c:function:: PyObject *PyErr_ProgramText(const char *filename, int lineno)

Similar to :c:func:`PyErr_ProgramTextObject`, but *filename* is a
:c:expr:`const char *`, which is decoded with the
:term:`filesystem encoding and error handler`, instead of a
Python object reference.


Issuing warnings
================

Expand Down
34 changes: 33 additions & 1 deletion Doc/c-api/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,32 @@ complete listing.

.. versionadded:: 3.4

.. c:macro:: Py_BUILD_ASSERT(cond)

Asserts a compile-time condition *cond*, as a statement.
The build will fail if the condition is false or cannot be evaluated at compile time.

For example::

Py_BUILD_ASSERT(sizeof(PyTime_t) == sizeof(int64_t));

.. versionadded:: 3.3

.. c:macro:: Py_BUILD_ASSERT_EXPR(cond)

Asserts a compile-time condition *cond*, as an expression that evaluates to ``0``.
The build will fail if the condition is false or cannot be evaluated at compile time.

For example::

#define foo_to_char(foo) \
((char *)(foo) + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0))

.. versionadded:: 3.3

.. c:macro:: PyDoc_STRVAR(name, str)

Creates a variable with name ``name`` that can be used in docstrings.
Creates a variable with name *name* that can be used in docstrings.
If Python is built without docstrings, the value will be empty.

Use :c:macro:`PyDoc_STRVAR` for docstrings to support building
Expand Down Expand Up @@ -267,6 +290,15 @@ complete listing.
{NULL, NULL}
};

.. c:macro:: PyDoc_VAR(name)

Declares a static character array variable with the given name *name*.

For example::

PyDoc_VAR(python_doc) = PyDoc_STR("A genus of constricting snakes in the Pythonidae family native "
"to the tropics and subtropics of the Eastern Hemisphere.");


.. _api-objects:

Expand Down
3 changes: 0 additions & 3 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,6 @@
# Temporary undocumented names.
# In future this list must be empty.
nitpick_ignore += [
# Undocumented public C macros
('c:macro', 'Py_BUILD_ASSERT'),
('c:macro', 'Py_BUILD_ASSERT_EXPR'),
# Do not error nit-picky mode builds when _SubParsersAction.add_parser cannot
# be resolved, as the method is currently undocumented. For context, see
# https://github.com/python/cpython/pull/103289.
Expand Down
Loading