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:
Victor Stinner 2023-10-20 19:29:27 +02:00 committed by GitHub
parent 264f4af506
commit d8f32be5b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 23 additions and 16 deletions

View file

@ -44,7 +44,7 @@ _posixshmem_shm_open_impl(PyObject *module, PyObject *path, int flags,
{
int fd;
int async_err = 0;
const char *name = PyUnicode_AsUTF8AndSize(path, NULL);
const char *name = PyUnicode_AsUTF8(path);
if (name == NULL) {
return -1;
}
@ -83,7 +83,7 @@ _posixshmem_shm_unlink_impl(PyObject *module, PyObject *path)
{
int rv;
int async_err = 0;
const char *name = PyUnicode_AsUTF8AndSize(path, NULL);
const char *name = PyUnicode_AsUTF8(path);
if (name == NULL) {
return NULL;
}