Skip to content

Commit 9a2ebfb

Browse files
committed
Add preprocesor directives to activate the temporary buffer when needed
1 parent 3fd50ee commit 9a2ebfb

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Modules/posixmodule.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5177,10 +5177,16 @@ enum posix_spawn_file_actions_identifier {
51775177
POSIX_SPAWN_DUP2
51785178
};
51795179

5180+
#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ < 20))
51805181
static int
51815182
parse_file_actions(PyObject *file_actions,
51825183
posix_spawn_file_actions_t *file_actionsp,
51835184
PyObject* temp_buffer)
5185+
#else
5186+
static int
5187+
parse_file_actions(PyObject *file_actions,
5188+
posix_spawn_file_actions_t *file_actionsp)
5189+
#endif
51845190
{
51855191
PyObject *seq;
51865192
PyObject *file_action = NULL;
@@ -5225,11 +5231,13 @@ parse_file_actions(PyObject *file_actions,
52255231
{
52265232
goto fail;
52275233
}
5234+
#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ < 20))
52285235
PyList_Append(temp_buffer, path);
5236+
#endif
52295237
errno = posix_spawn_file_actions_addopen(file_actionsp,
52305238
fd, PyBytes_AS_STRING(path), oflag, (mode_t)mode);
52315239
/* addopen copies the value except for some old versions of
5232-
* glibc (<2.26). The usage of temp_buffer is a workaround
5240+
* glibc (<2.20). The usage of temp_buffer is a workaround
52335241
* to keep this temporary objects alive until posix_spawn
52345242
* gets called.*/
52355243
Py_DECREF(path);
@@ -5361,8 +5369,10 @@ os_posix_spawn_impl(PyObject *module, path_t *path, PyObject *argv,
53615369
* helper functions for manipulating file actions not copy the provided
53625370
* buffers. The use of `temp_buffer` here is a workaround that keeps the
53635371
* python objects that own the buffers alive until posix_spawn gets called.
5364-
* Check https://bugs.python.org/issue33630 for more info. */
5372+
* Check https://bugs.python.org/issue33630 and
5373+
* https://sourceware.org/bugzilla/show_bug.cgi?id=17048 for more info. */
53655374

5375+
#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ < 20))
53665376
temp_buffer = PyList_New(0);
53675377

53685378
if (!temp_buffer) {
@@ -5371,6 +5381,11 @@ os_posix_spawn_impl(PyObject *module, path_t *path, PyObject *argv,
53715381
if (parse_file_actions(file_actions, &file_actions_buf, temp_buffer)) {
53725382
goto exit;
53735383
}
5384+
#else
5385+
if (parse_file_actions(file_actions, &file_actions_buf)) {
5386+
goto exit;
5387+
}
5388+
#endif
53745389
file_actionsp = &file_actions_buf;
53755390
}
53765391

0 commit comments

Comments
 (0)