Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9ad853b

Browse files
committed
Patch #788404: ignore "b" and "t" mode modifiers in posix_popen.
Fixes #703198. Backported to 2.3.
1 parent 9885c93 commit 9ad853b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Modules/posixmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4348,6 +4348,11 @@ posix_popen(PyObject *self, PyObject *args)
43484348
PyObject *f;
43494349
if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize))
43504350
return NULL;
4351+
/* Strip mode of binary or text modifiers */
4352+
if (strcmp(mode, "rb") == 0 || strcmp(mode, "rt") == 0)
4353+
mode = "r";
4354+
else if (strcmp(mode, "wb") == 0 || strcmp(mode, "wt") == 0)
4355+
mode = "w";
43514356
Py_BEGIN_ALLOW_THREADS
43524357
fp = popen(name, mode);
43534358
Py_END_ALLOW_THREADS

0 commit comments

Comments
 (0)