From: Martin v. Löwis Date: Fri, 31 Oct 2003 10:01:37 +0000 (+0000) Subject: Patch #788404: ignore "b" and "t" mode modifiers in posix_popen. X-Git-Tag: v2.3.3c1~100 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f62fad7442011b98b326341a82365b2a5f5daca7;p=thirdparty%2FPython%2Fcpython.git Patch #788404: ignore "b" and "t" mode modifiers in posix_popen. Fixes #703198. --- diff --git a/Misc/NEWS b/Misc/NEWS index 526943834742..101dc0a8428e 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -18,6 +18,8 @@ Core and builtins Extension modules ----------------- +- Bug #703198: Ignore "b" and "t" in os.popen on Unix. + - Patch #803998: Deal with errors in SSL_write correctly. - The xml.parsers.expat module now provides Expat 1.95.7. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 4cb2042546b1..11df9903d56c 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -4330,6 +4330,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