8000 gh-85283: Build posixshmem extension with Limited C API (#111087) · python/cpython@8d234cd · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d234cd

Browse files
authored
gh-85283: Build posixshmem extension with Limited C API (#111087)
Build the _multiprocessing.posixshmem extension with the Limited C API. * Add <errno.h> include. * Replace PyUnicode_AsUTF8() with PyUnicode_AsUTF8AndSize().
1 parent 9376728 commit 8d234cd

File tree

4 files changed

+24
-104
lines changed

4 files changed

+24
-104
lines changed

Doc/whatsnew/3.13.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,8 +938,9 @@ Build Changes
938938
library, GCC built-in atomic functions, or MSVC interlocked intrinsics.
939939

940940
* The ``errno``, ``md5``, ``resource``, ``winsound``, ``_ctypes_test``,
941-
``_scproxy``, ``_stat``, ``_testimportmultiple`` and ``_uuid`` C extensions
942-
are now built with the :ref:`limited C API <limited-c-api>`.
941+
``_multiprocessing.posixshmem``, ``_scproxy``, ``_stat``,
942+
``_testimportmultiple`` and ``_uuid`` C extensions are now built with the
943+
:ref:`limited C API <limited-c-api>`.
943944
(Contributed by Victor Stinner in :gh:`85283`.)
944945

945946

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
The ``errno``, ``md5``, ``resource``, ``winsound``, ``_ctypes_test``,
2-
``_scproxy``, ``_stat``, ``_testimportmultiple`` and ``_uuid`` C extensions are
3-
now built with the :ref:`limited C API <limited-c-api>`.
2+
``_multiprocessing.posixshmem``, ``_scproxy``, ``_stat``,
3+
``_testimportmultiple`` and ``_uuid`` C extensions are now built with the
4+
:ref:`limited C API <limited-c-api>`.
45
Patch by Victor Stinner.

Modules/_multiprocessing/clinic/posixshmem.c.h

Lines changed: 11 additions & 92 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_multiprocessing/posixshmem.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22
posixshmem - A Python extension that provides shm_open() and shm_unlink()
33
*/
44

5-
// clinic/posixshmem.c.h uses internal pycore_modsupport.h API
6-
#ifndef Py_BUILD_CORE_BUILTIN
7-
# define Py_BUILD_CORE_MODULE 1
8-
#endif
5+
// Need limited C API version 3.13 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
6+
#define Py_LIMITED_API 0x030d0000
97

108
#include <Python.h>
119

12-
// for shm_open() and shm_unlink()
10+
#include <errno.h> // EINTR
1311
#ifdef HAVE_SYS_MMAN_H
14-
#include <sys/mman.h>
12+
# include <sys/mman.h> // shm_open(), shm_unlink()
1513
#endif
1614

15+
1716
/*[clinic input]
1817
module _posixshmem
1918
[clinic start generated code]*/
@@ -45,7 +44,7 @@ _posixshmem_shm_open_impl(PyObject *module, PyObject *path, int flags,
4544
{
4645
int fd;
4746
int async_err = 0;
48-
const char *name = PyUnicode_AsUTF8(path);
47+
const char *name = PyUnicode_AsUTF8AndSize(path, NULL);
4948
if (name == NULL) {
5049
return -1;
5150
}
@@ -84,7 +83,7 @@ _posixshmem_shm_unlink_impl(PyObject *module, PyObject *path)
8483
{
8584
int rv;
8685
int async_err = 0;
87-
const char *name = PyUnicode_AsUTF8(path);
86+
const char *name = PyUnicode_AsUTF8AndSize(path, NULL);
8887
if (name == NULL) {
8988
return NULL;
9089
}

0 commit comments

Comments
 (0)
0