diff options
author | Victor Stinner <vstinner@python.org> | 2023-10-20 18:03:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-20 18:03:11 (GMT) |
commit | f1e751e933aa8c39c0e9cfa4cdc3f8f9f0538202 (patch) | |
tree | 78e958a08e7f3e7448f110bc8755b2e4343acec1 /Doc | |
parent | d8f32be5b6a736dc2fc9dca3f1bf176c82fc9b44 (diff) | |
download | cpython-f1e751e933aa8c39c0e9cfa4cdc3f8f9f0538202.zip cpython-f1e751e933aa8c39c0e9cfa4cdc3f8f9f0538202.tar.gz cpython-f1e751e933aa8c39c0e9cfa4cdc3f8f9f0538202.tar.bz2 |
gh-111089: PyUnicode_AsUTF8AndSize() sets size on error (#111106)
On error, PyUnicode_AsUTF8AndSize() now sets the size argument to -1,
to avoid undefined value.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/c-api/unicode.rst | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index d17e63d..5fa3796 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -971,8 +971,8 @@ These are the UTF-8 codec APIs: returned buffer always has an extra null byte appended (not included in *size*), regardless of whether there are any other null code points. - In the case of an error, ``NULL`` is returned with an exception set and no - *size* is stored. + On error, set an exception, set *size* to ``-1`` (if it's not NULL) and + return ``NULL``. This caches the UTF-8 representation of the string in the Unicode object, and subsequent calls will return a pointer to the same buffer. The caller is not |