mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
gh-111089: Add PyUnicode_AsUTF8() to the limited C API (#111121)
Add PyUnicode_AsUTF8() function to the limited C API. multiprocessing posixshmem now uses PyUnicode_AsUTF8() instead of PyUnicode_AsUTF8AndSize(): the extension is built with the limited C API. The function now raises an exception if the filename contains an embedded null character instead of truncating silently the filename.
This commit is contained in:
parent
264f4af506
commit
d8f32be5b6
9 changed files with 23 additions and 16 deletions
|
@ -443,7 +443,17 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String(
|
|||
PyObject *unicode /* Unicode object */
|
||||
);
|
||||
|
||||
// Returns a pointer to the default encoding (UTF-8) of the
|
||||
// Returns a pointer to the UTF-8 encoding of the Unicode object unicode.
|
||||
//
|
||||
// Raise an exception if the string contains embedded null characters.
|
||||
// Use PyUnicode_AsUTF8AndSize() to accept embedded null characters.
|
||||
//
|
||||
// This function caches the UTF-8 encoded string in the Unicode object
|
||||
// and subsequent calls will return the same string. The memory is released
|
||||
// when the Unicode object is deallocated.
|
||||
PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode);
|
||||
|
||||
// Returns a pointer to the UTF-8 encoding of the
|
||||
// Unicode object unicode and the size of the encoded representation
|
||||
// in bytes stored in `*size` (if size is not NULL).
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue