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:
1098
1098
.. versionchanged:: 3.7
1099
1099
The return type is now ``const char *`` rather of ``char *``.
1100
1100
1101
+ .. versionchanged:: 3.10
1102
+ This function is a part of the :ref:`limited API <stable>`.
1103
+
1101
1104
1102
1105
.. c:function:: const char* PyUnicode_AsUTF8(PyObject *unicode)
1103
1106
Original file line number Diff line number Diff line change @@ -323,6 +323,10 @@ New Features
323
323
sending value into iterator without raising ``StopIteration `` exception.
324
324
(Contributed by Vladimir Matveev in :issue: `41756 `.)
325
325
326
+ * Added :c:func: `PyUnicode_AsUTF8AndSize ` to the limited C API.
327
+ (Contributed by Alex Gaynor in :issue: `41784 `.)
328
+
329
+
326
330
Porting to Python 3.10
327
331
----------------------
328
332
Original file line number Diff line number Diff line change @@ -726,26 +726,6 @@ PyAPI_FUNC(int) _PyUnicode_FormatAdvancedWriter(
726
726
727
727
/* --- Manage the default encoding ---------------------------------------- */
728
728
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
-
749
729
/* Returns a pointer to the default encoding (UTF-8) of the
750
730
Unicode object unicode.
751
731
Original file line number Diff line number Diff line change @@ -468,6 +468,23 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String(
468
468
PyObject * unicode /* Unicode object */
469
469
);
470
470
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
+
471
488
/* --- UTF-32 Codecs ------------------------------------------------------ */
472
489
473
490
/* 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)
568
568
EXPORT_FUNC (PyUnicode_AsUnicodeEscapeString )
569
569
EXPORT_FUNC (PyUnicode_AsUTF16String )
570
570
EXPORT_FUNC (PyUnicode_AsUTF32String )
571
+ EXPORT_FUNC (PyUnicode_AsUTF8AndSize )
571
572
EXPORT_FUNC (PyUnicode_AsUTF8String )
572
573
EXPORT_FUNC (PyUnicode_AsWideChar )
573
574
EXPORT_FUNC (PyUnicode_AsWideCharString )
You can’t perform that action at this time.
0 commit comments