From c7f165fe652651c32833245fc902c790a4f173fa Mon Sep 17 00:00:00 2001 From: Oren Milman Date: Fri, 15 Sep 2017 10:20:11 +0300 Subject: [PATCH] [2.7] bpo-31471: Fix assertion failure in subprocess.Popen() on Windows, in case env has a bad keys() method. (GH-3580) (#3595) --- PC/_subprocess.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/PC/_subprocess.c b/PC/_subprocess.c index f73d14f579..fc9aaa4611 100644 --- a/PC/_subprocess.c +++ b/PC/_subprocess.c @@ -341,9 +341,13 @@ getenvironment(PyObject* environment) envsize = PyMapping_Length(environment); keys = PyMapping_Keys(environment); + if (!keys) { + return NULL; + } values = PyMapping_Values(environment); - if (!keys || !values) + if (!values) { goto error; + } out = PyString_FromStringAndSize(NULL, 2048); if (! out) -- 2.50.1