File tree Expand file tree Collapse file tree 6 files changed +26
-20
lines changed
Expand file tree Collapse file tree 6 files changed +26
-20
lines changed Original file line number Diff line number Diff line change @@ -1098,6 +1098,9 @@ These are the UTF-8 codec APIs:
10981098 .. versionchanged:: 3.7
10991099 The return type is now ``const char *`` rather of ``char *``.
11001100
1101+ .. versionchanged:: 3.10
1102+ This function is a part of the :ref:`limited API <stable>`.
1103+
11011104
11021105.. c:function:: const char* PyUnicode_AsUTF8(PyObject *unicode)
11031106
Original file line number Diff line number Diff line change @@ -323,6 +323,10 @@ New Features
323323 sending value into iterator without raising ``StopIteration `` exception.
324324 (Contributed by Vladimir Matveev in :issue: `41756 `.)
325325
326+ * Added :c:func: `PyUnicode_AsUTF8AndSize ` to the limited C API.
327+ (Contributed by Alex Gaynor in :issue: `41784 `.)
328+
329+
326330Porting to Python 3.10
327331----------------------
328332
Original file line number Diff line number Diff line change @@ -726,26 +726,6 @@ PyAPI_FUNC(int) _PyUnicode_FormatAdvancedWriter(
726726
727727/* --- Manage the default encoding ---------------------------------------- */
728728
729- /* Returns a pointer to the default encoding (UTF-8) of the
730- Unicode object unicode and the size of the encoded representation
731- in bytes stored in *size.
732-
733- In case of an error, no *size is set.
734-
735- This function caches the UTF-8 encoded string in the unicodeobject
736- and subsequent calls will return the same string. The memory is released
737- when the unicodeobject is deallocated.
738-
739- _PyUnicode_AsStringAndSize is a #define for PyUnicode_AsUTF8AndSize to
740- support the previous internal function with the same behaviour.
741- */
742-
743- PyAPI_FUNC (const char *) PyUnicode_AsUTF8AndSize(
744- PyObject *unicode,
745- Py_ssize_t *size);
746-
747- #define _PyUnicode_AsStringAndSize PyUnicode_AsUTF8AndSize
748-
749729/* Returns a pointer to the default encoding (UTF-8) of the
750730 Unicode object unicode.
751731
Original file line number Diff line number Diff line change @@ -468,6 +468,23 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String(
468468 PyObject * unicode /* Unicode object */
469469 );
470470
471+ /* Returns a pointer to the default encoding (UTF-8) of the
472+ Unicode object unicode and the size of the encoded representation
473+ in bytes stored in *size.
474+
475+ In case of an error, no *size is set.
476+
477+ This function caches the UTF-8 encoded string in the unicodeobject
478+ and subsequent calls will return the same string. The memory is released
479+ when the unicodeobject is deallocated.
480+ */
481+
482+ #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 >= 0x030A0000
483+ PyAPI_FUNC (const char * ) PyUnicode_AsUTF8AndSize (
484+ PyObject * unicode ,
485+ Py_ssize_t * size );
486+ #endif
487+
471488/* --- UTF-32 Codecs ------------------------------------------------------ */
472489
473490/* Decodes length bytes from a UTF-32 encoded buffer string and returns
Original file line number Diff line number Diff line change 1+ Added ``PyUnicode_AsUTF8AndSize `` to the limited C API.
Original file line number Diff line number Diff line change @@ -568,6 +568,7 @@ EXPORT_FUNC(PyUnicode_AsUCS4Copy)
568568EXPORT_FUNC (PyUnicode_AsUnicodeEscapeString )
569569EXPORT_FUNC (PyUnicode_AsUTF16String )
570570EXPORT_FUNC (PyUnicode_AsUTF32String )
571+ EXPORT_FUNC (PyUnicode_AsUTF8AndSize )
571572EXPORT_FUNC (PyUnicode_AsUTF8String )
572573EXPORT_FUNC (PyUnicode_AsWideChar )
573574EXPORT_FUNC (PyUnicode_AsWideCharString )
You can’t perform that action at this time.
0 commit comments