FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-156939: Document that PyASCIIObject ends with null byte by vstinner · Pull Request #157708 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
31 changes: 28 additions & 3 deletions Doc/c-api/unicode.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
Loading

Back | FazBrowse Home | New Git URL