From f62fad7442011b98b326341a82365b2a5f5daca7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Fri, 31 Oct 2003 10:01:37 +0000 Subject: [PATCH] Patch #788404: ignore "b" and "t" mode modifiers in posix_popen. Fixes #703198. --- Misc/NEWS | 2 ++ Modules/posixmodule.c | 5 +++++ 2 files changed, 7 insertions(+) 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 -- 2.47.3