[Python-checkins] Document the lifetime of `PyUnicode_AsUTF8String` (GH-92325)

miss-islington webhook-mailer at python.org
Fri May 6 05:55:05 EDT 2022


https://github.com/python/cpython/commit/367faf71eae963e613cb4404e24748c91baa4190
commit: 367faf71eae963e613cb4404e24748c91baa4190
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-05-06T02:55:01-07:00
summary:

Document the lifetime of `PyUnicode_AsUTF8String` (GH-92325)


The current wording implied this, but didn't state it explicitly.
(cherry picked from commit 740da8d37a84638f4a8893bee3648f36fc6beb0f)

Co-authored-by: Matt Wozniski <godlygeek at gmail.com>

files:
M Doc/c-api/unicode.rst

diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst
index a08cebcc000d0..cf7d2232125c8 100644
--- a/Doc/c-api/unicode.rst
+++ b/Doc/c-api/unicode.rst
@@ -1093,7 +1093,8 @@ These are the UTF-8 codec APIs:
 
    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
-   responsible for deallocating the buffer.
+   responsible for deallocating the buffer. The buffer is deallocated and
+   pointers to it become invalid when the Unicode object is garbage collected.
 
    .. versionadded:: 3.3
 



More information about the Python-checkins mailing list