From b6a912e48a3d9f683e2b57994309a3d1c95452e0 Mon Sep 17 00:00:00 2001 From: Matt Wozniski Date: Thu, 5 May 2022 03:30:53 -0400 Subject: [PATCH] Document the lifetime of `PyUnicode_AsUTF8String` The current wording implied this, but didn't state it explicitly. --- Doc/c-api/unicode.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 00faac5b69abdb4..d139112578ca996 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -1075,7 +1075,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