summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2003-10-31 10:01:53 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2003-10-31 10:01:53 (GMT)
commit9ad853bc371e420b20dacbfe00af9da2ba5d3b6d (patch)
tree3cf8fcbd54ffdf4aa26c396b2cef9816eae07597 /Modules
parent9885c93b9975542c63d6f567ea7113865f04bc2f (diff)
downloadcpython-9ad853bc371e420b20dacbfe00af9da2ba5d3b6d.zip
cpython-9ad853bc371e420b20dacbfe00af9da2ba5d3b6d.tar.gz
cpython-9ad853bc371e420b20dacbfe00af9da2ba5d3b6d.tar.bz2
Patch #788404: ignore "b" and "t" mode modifiers in posix_popen.
Fixes #703198. Backported to 2.3.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index a882023..9c58c9d 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -4348,6 +4348,11 @@ posix_popen(PyObject *self, PyObject *args)
PyObject *f;
if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize))
return NULL;
+ /* Strip mode of binary or text modifiers */
+ if (strcmp(mode, "rb") == 0 || strcmp(mode, "rt") == 0)
+ mode = "r";
+ else if (strcmp(mode, "wb") == 0 || strcmp(mode, "wt") == 0)
+ mode = "w";
Py_BEGIN_ALLOW_THREADS
fp = popen(name, mode);
Py_END_ALLOW_THREADS