]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patch #788404: ignore "b" and "t" mode modifiers in posix_popen.
authorMartin v. Löwis <martin@v.loewis.de>
Fri, 31 Oct 2003 10:01:37 +0000 (10:01 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Fri, 31 Oct 2003 10:01:37 +0000 (10:01 +0000)
Fixes #703198.

Misc/NEWS
Modules/posixmodule.c

index 526943834742e3d77c9c532059ed84b49f1de0f5..101dc0a8428e7025de2169dc813974a6a1727904 100644 (file)
--- 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.
index 4cb2042546b1949a04f7c0937937eae820c14452..11df9903d56cd077e23ccffa371bef19c12ec098 100644 (file)
@@ -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