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: 2 additions & 2 deletions Doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ lock:
# Dependencies have a 14 day cooldown period to mitigate supply chain attacks,
# except for sphinx_linklint and python-docs-theme, which are maintained by
# core team members.
uv pip compile requirements.txt \
--exclude-newer P14D \
$(UV) pip compile requirements.txt \
--upgrade --exclude-newer P14D \
--exclude-newer-package sphinx_linklint=PT0S \
--exclude-newer-package python-docs-theme=PT0S \
--no-cache --output-file $(REQUIREMENTS) \
Expand Down
31 changes: 28 additions & 3 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ points must be below 1114112 (which is the full Unicode range).

UTF-8 representation is created on demand and cached in the Unicode object.

.. impl-detail::

The internal buffer always includes an extra trailing null character for
compatibility with null terminated C strings. This extra character is not
counted in :c:func:`PyUnicode_GetLength` nor in the various *size* arguments
of the functions below.

.. note::
The :c:type:`Py_UNICODE` representation has been removed since Python 3.12
with deprecated APIs.
Expand Down Expand Up @@ -164,11 +171,15 @@ access to internal read-only data of Unicode objects:
.. versionadded:: 3.3


.. c:function:: Py_UCS4 PyUnicode_READ(int kind, void *data, \
Py_ssize_t index)
.. c:function:: Py_UCS4 PyUnicode_READ(int kind, void *data, Py_ssize_t index)

Read a code point from a canonical representation *data* (as obtained with
:c:func:`PyUnicode_DATA`). No checks or ready calls are performed.
:c:func:`PyUnicode_DATA`). No checks are performed.

.. impl-detail::

Accept reading the trailing null character at index
:c:func:`PyUnicode_GetLength`.

.. versionadded:: 3.3

Expand All @@ -179,6 +190,11 @@ access to internal read-only data of Unicode objects:
representation. This is less efficient than :c:func:`PyUnicode_READ` if you
do multiple consecutive reads.

.. impl-detail::

Accept reading the trailing null character at index
:c:func:`PyUnicode_GetLength`.

.. versionadded:: 3.3


Expand Down Expand Up @@ -716,6 +732,10 @@ APIs:

On error, set an exception and return ``-1``.

.. impl-detail::

The length does not count the trailing null character.

.. versionadded:: 3.3


Expand Down Expand Up @@ -794,6 +814,11 @@ APIs:

Return character on success, ``-1`` on error with an exception set.

.. impl-detail::

Do not accept reading the trailing null character at index
:c:func:`PyUnicode_GetLength`.

.. versionadded:: 3.3


Expand Down
37 changes: 37 additions & 0 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,3 +636,40 @@
"library/threadsafety.rst": "builtins/threadsafety.rst",
"library/time-complexity.rst": "builtins/time-complexity.rst",
}

# Refuse to run the doctest builder under a mismatched Python
# -----------------------------------------------------------


def _check_doctest_interpreter(app):
# The doctests are executed by the interpreter running Sphinx,
# so refuse to run them if its version doesn't match the source tree.
if app.builder.name != "doctest":
return

running_version = f"{sys.version_info.major}.{sys.version_info.minor}"
if running_version != version:
from sphinx.util import logging as sphinx_logging

logger = sphinx_logging.getLogger(__name__)
logger.error(
"The doctests are executed by the Python running Sphinx, "
"which is Python %s, however this source tree is Python %s, "
"so they would test Python %s rather than the code "
"documented here.\n"
"Recreate the venv with a matching interpreter, for example: "
"'make clean-venv && make venv PYTHON=../python'.",
running_version,
version,
running_version,
)
raise SystemExit(1)


def setup(app):
app.connect("builder-inited", _check_doctest_interpreter)
return {
"version": "1.0",
"parallel_read_safe": True,
"parallel_write_safe": True,
}
44 changes: 44 additions & 0 deletions Doc/library/ctypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3383,3 +3383,47 @@ Exceptions
.. availability:: Windows

.. versionadded:: 3.14


Library version
^^^^^^^^^^^^^^^

The following constants are only available if :mod:`!ctypes` was built with
libffi 3.5 or later, which is the first version providing this information.

.. data:: LIBFFI_VERSION

The version string of the libffi library that was used for building
the module, like ``'3.5.2'``.
This may be different from the libffi library actually used at runtime,
which is available as :const:`libffi_version`.

.. versionadded:: next

.. data:: libffi_version

The version string of the libffi library actually loaded by the interpreter.

.. versionadded:: next

.. data:: LIBFFI_VERSION_INFO

A named tuple containing the three components of the libffi library
version that was used for building the module:
*major*, *minor*, and *patch*.
All values are integers.
The components can also be accessed by name,
so ``ctypes.LIBFFI_VERSION_INFO[0]`` is equivalent to
``ctypes.LIBFFI_VERSION_INFO.major`` and so on.
This may be different from the libffi library actually used at runtime,
which is available as :const:`libffi_version_info`.

.. versionadded:: next

.. data:: libffi_version_info

A named tuple containing the version of the libffi library
actually loaded by the interpreter,
with the same fields as :const:`LIBFFI_VERSION_INFO`.

.. versionadded:: next
19 changes: 19 additions & 0 deletions Doc/library/turtle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2571,6 +2571,25 @@ Public classes
* ``a.rotate(angle)`` rotation


Exceptions
==========

The :mod:`!turtle` module defines the following exception:

.. exception:: TurtleGraphicsError

Raised for invalid arguments or operations.
For example, a malformed color string:

.. doctest::
:skipif: _tkinter is None

>>> turtle.color("blau")
Traceback (most recent call last):
...
turtle.TurtleGraphicsError: bad color string: blau


.. _turtle-explanation:

Explanation
Expand Down
Loading
Loading