[issue31471] assertion failure in subprocess.Popen() in case the env arg has a bad keys() method

Oren Milman report at bugs.python.org
Thu Sep 14 12:42:10 EDT 2017


New submission from Oren Milman:

The following code causes an assertion failure on Windows:
class BadEnv(dict):
    keys = None

import subprocess

import sys

subprocess.Popen([sys.executable, "-c", "pass"], env=BadEnv())


this is because getenvironment() (in Modules/_winapi.c) calls PyMapping_Values()
immediately after calling PyMapping_Keys().
calling PyMapping_Values() ultimately leads to calling _PyObject_FastCallDict(),
which does 'assert(!PyErr_Occurred());'.
thus, in case of an error in PyMapping_Keys(), the assertion fails.

----------
components: Extension Modules
messages: 302181
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: assertion failure in subprocess.Popen() in case the env arg has a bad keys() method
type: crash
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31471>
_______________________________________


More information about the Python-bugs-list mailing list