diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 3683a48b7ad..cb9bbddc8c6 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -271,7 +271,11 @@ def test_empty_PYTHONPATH_issue16309(self): def test_displayhook_unencodable(self): for encoding in ('ascii', 'latin-1', 'utf-8'): - env = os.environ.copy() + # We are testing a PYTHON environment variable here, so we can't + # use -E, -I, or script_helper (which uses them). So instead we do + # poor-man's isolation by deleting the PYTHON vars from env. + env = {key:value for (key,value) in os.environ.copy().items() + if not key.startswith('PYTHON')} env['PYTHONIOENCODING'] = encoding p = subprocess.Popen( [sys.executable, '-i'],