Skip to content

Commit c7f165f

Browse files
orenmnserhiy-storchaka
authored andcommitted
[2.7] bpo-31471: Fix assertion failure in subprocess.Popen() on Windows, in case env has a bad keys() method. (GH-3580) (#3595)
1 parent a72d15c commit c7f165f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

PC/_subprocess.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,13 @@ getenvironment(PyObject* environment)
341341
envsize = PyMapping_Length(environment);
342342

343343
keys = PyMapping_Keys(environment);
344+
if (!keys) {
345+
return NULL;
346+
}
344347
values = PyMapping_Values(environment);
345-
if (!keys || !values)
348+
if (!values) {
346349
goto error;
350+
}
347351

348352
out = PyString_FromStringAndSize(NULL, 2048);
349353
if (! out)

0 commit comments

Comments
 (0)