Skip to content

Commit f632964

Browse files
committed
[3.11] gh-103883: Doc: Move PyUnicode_FromObject doc (GH-103913)
This API is one of Unicode creator APIs.. (cherry picked from commit ce2383e) Co-authored-by: Inada Naoki <[email protected]>
1 parent c0b538b commit f632964

File tree

1 file changed

+9
-82
lines changed

1 file changed

+9
-82
lines changed

Doc/c-api/unicode.rst

+9-82
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,15 @@ APIs:
572572
arguments.
573573
574574
575+
.. c:function:: PyObject* PyUnicode_FromObject(PyObject *obj)
576+
577+
Copy an instance of a Unicode subtype to a new true Unicode object if
578+
necessary. If *obj* is already a true Unicode object (not a subtype),
579+
return the reference with incremented refcount.
580+
581+
Objects other than Unicode or its subtypes will cause a :exc:`TypeError`.
582+
583+
575584
.. c:function:: PyObject* PyUnicode_FromEncodedObject(PyObject *obj, \
576585
const char *encoding, const char *errors)
577586
@@ -679,88 +688,6 @@ APIs:
679688
.. versionadded:: 3.3
680689
681690
682-
Deprecated Py_UNICODE APIs
683-
""""""""""""""""""""""""""
684-
685-
.. deprecated-removed:: 3.3 3.12
686-
687-
These API functions are deprecated with the implementation of :pep:`393`.
688-
Extension modules can continue using them, as they will not be removed in Python
689-
3.x, but need to be aware that their use can now cause performance and memory hits.
690-
691-
692-
.. c:function:: PyObject* PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size)
693-
694-
Create a Unicode object from the Py_UNICODE buffer *u* of the given size. *u*
695-
may be ``NULL`` which causes the contents to be undefined. It is the user's
696-
responsibility to fill in the needed data. The buffer is copied into the new
697-
object.
698-
699-
If the buffer is not ``NULL``, the return value might be a shared object.
700-
Therefore, modification of the resulting Unicode object is only allowed when
701-
*u* is ``NULL``.
702-
703-
If the buffer is ``NULL``, :c:func:`PyUnicode_READY` must be called once the
704-
string content has been filled before using any of the access macros such as
705-
:c:func:`PyUnicode_KIND`.
706-
707-
.. deprecated-removed:: 3.3 3.12
708-
Part of the old-style Unicode API, please migrate to using
709-
:c:func:`PyUnicode_FromKindAndData`, :c:func:`PyUnicode_FromWideChar`, or
710-
:c:func:`PyUnicode_New`.
711-
712-
713-
.. c:function:: Py_UNICODE* PyUnicode_AsUnicode(PyObject *unicode)
714-
715-
Return a read-only pointer to the Unicode object's internal
716-
:c:type:`Py_UNICODE` buffer, or ``NULL`` on error. This will create the
717-
:c:expr:`Py_UNICODE*` representation of the object if it is not yet
718-
available. The buffer is always terminated with an extra null code point.
719-
Note that the resulting :c:type:`Py_UNICODE` string may also contain
720-
embedded null code points, which would cause the string to be truncated when
721-
used in most C functions.
722-
723-
.. deprecated-removed:: 3.3 3.12
724-
Part of the old-style Unicode API, please migrate to using
725-
:c:func:`PyUnicode_AsUCS4`, :c:func:`PyUnicode_AsWideChar`,
726-
:c:func:`PyUnicode_ReadChar` or similar new APIs.
727-
728-
729-
.. c:function:: Py_UNICODE* PyUnicode_AsUnicodeAndSize(PyObject *unicode, Py_ssize_t *size)
730-
731-
Like :c:func:`PyUnicode_AsUnicode`, but also saves the :c:func:`Py_UNICODE`
732-
array length (excluding the extra null terminator) in *size*.
733-
Note that the resulting :c:expr:`Py_UNICODE*` string
734-
may contain embedded null code points, which would cause the string to be
735-
truncated when used in most C functions.
736-
737-
.. versionadded:: 3.3
738-
739-
.. deprecated-removed:: 3.3 3.12
740-
Part of the old-style Unicode API, please migrate to using
741-
:c:func:`PyUnicode_AsUCS4`, :c:func:`PyUnicode_AsWideChar`,
742-
:c:func:`PyUnicode_ReadChar` or similar new APIs.
743-
744-
745-
.. c:function:: Py_ssize_t PyUnicode_GetSize(PyObject *unicode)
746-
747-
Return the size of the deprecated :c:type:`Py_UNICODE` representation, in
748-
code units (this includes surrogate pairs as 2 units).
749-
750-
.. deprecated-removed:: 3.3 3.12
751-
Part of the old-style Unicode API, please migrate to using
752-
:c:func:`PyUnicode_GET_LENGTH`.
753-
754-
755-
.. c:function:: PyObject* PyUnicode_FromObject(PyObject *obj)
756-
757-
Copy an instance of a Unicode subtype to a new true Unicode object if
758-
necessary. If *obj* is already a true Unicode object (not a subtype),
759-
return the reference with incremented refcount.
760-
761-
Objects other than Unicode or its subtypes will cause a :exc:`TypeError`.
762-
763-
764691
Locale Encoding
765692
"""""""""""""""
766693

0 commit comments

Comments
 (0)