@@ -168,8 +168,14 @@ access to internal read-only data of Unicode objects:
168168 The function performs no checks for any of its requirements,
169169 and is intended for usage in loops.
170170
171+ While :class: `str ` objects are usually immutable in Python, this special C API allows
172+ mutating a fresh :class: `str ` object if the string has not been "used" yet.
173+
171174 .. versionadded :: 3.3
172175
176+ .. soft-deprecated :: next
177+ Use the :c:type: `PyUnicodeWriter ` API instead.
178+
173179
174180.. c :function :: Py_UCS4 PyUnicode_READ (int kind, void *data, Py_ssize_t index)
175181
@@ -407,9 +413,15 @@ APIs:
407413 using the :c:type: `PyUnicodeWriter ` API, or one of the ``PyUnicode_From* ``
408414 functions below.
409415
416+ While :class: `str ` objects are usually immutable in Python, this special C API
417+ returns a :class: `str ` object that can be mutated, except if *size * is zero, in which
418+ case it returns the immutable empty string constant.
410419
411420 .. versionadded :: 3.3
412421
422+ .. soft-deprecated :: next
423+ Use the :c:type: `PyUnicodeWriter ` API instead.
424+
413425
414426.. c :function :: PyObject* PyUnicode_FromKindAndData (int kind, const void *buffer, \
415427 Py_ssize_t size)
@@ -754,11 +766,16 @@ APIs:
754766 possible. Returns ``-1 `` and sets an exception on error, otherwise returns
755767 the number of copied characters.
756768
757- The string must not have been “used” yet.
769+ While :class: `str ` objects are usually immutable in Python, this special C API allows
770+ mutating a fresh :class: `str ` object if the string has not been "used" yet.
771+
758772 See :c:func: `PyUnicode_New ` for details.
759773
760774 .. versionadded :: 3.3
761775
776+ .. soft-deprecated :: next
777+ Use the :c:type: `PyUnicodeWriter ` API instead.
778+
762779
763780.. c :function :: int PyUnicode_Resize (PyObject **unicode, Py_ssize_t length);
764781
@@ -774,6 +791,14 @@ APIs:
774791 The function doesn't check string content, the result may not be a
775792 string in canonical representation.
776793
794+ While :class:`str` objects are usually immutable in Python, this special C API
795+ can resize a :class:`str` object in-place if the string has not been "used" yet.
796+ It returns a :class:`str` object which can be mutated, except if *size* is zero, in
797+ which case it returns the immutable empty string constant.
798+
799+ .. soft-deprecated:: next
800+ Use the :c:type:`PyUnicodeWriter` API instead.
801+
777802
778803.. c:function:: Py_ssize_t PyUnicode_Fill(PyObject *unicode, Py_ssize_t start, \
779804 Py_ssize_t length, Py_UCS4 fill_char)
@@ -784,14 +809,19 @@ APIs:
784809 Fail if *fill_char * is bigger than the string maximum character, or if the
785810 string has more than 1 reference.
786811
787- The string must not have been “used” yet.
788- See :c:func: `PyUnicode_New ` for details.
789-
790812 Return the number of written characters, or return ``-1 `` and raise an
791813 exception on error.
792814
815+ While :class: `str ` objects are usually immutable in Python, this special C API allows
816+ mutating a fresh :class: `str ` object if the string has not been "used" yet.
817+
818+ See :c:func: `PyUnicode_New ` for details.
819+
793820 .. versionadded :: 3.3
794821
822+ .. soft-deprecated :: next
823+ Use the :c:type: `PyUnicodeWriter ` API instead.
824+
795825
796826.. c :function :: int PyUnicode_WriteChar (PyObject *unicode, Py_ssize_t index, \
797827 Py_UCS4 character)
@@ -804,11 +834,16 @@ APIs:
804834 See :c:func: `PyUnicode_WRITE ` for a version that skips these checks,
805835 making them your responsibility.
806836
807- The string must not have been “used” yet.
837+ While :class: `str ` objects are usually immutable in Python, this special C API allows
838+ mutating a fresh :class: `str ` object if the string has not been "used" yet.
839+
808840 See :c:func: `PyUnicode_New ` for details.
809841
810842 .. versionadded :: 3.3
811843
844+ .. soft-deprecated :: next
845+ Use the :c:type: `PyUnicodeWriter ` API instead.
846+
812847
813848.. c :function :: Py_UCS4 PyUnicode_ReadChar (PyObject *unicode, Py_ssize_t index)
814849
0 commit comments