From: R David Murray Date: Tue, 14 Apr 2015 21:57:41 +0000 (-0400) Subject: #23925: stop (eg) PYTHONSTARTUP from causing test_cmd_line failure. X-Git-Tag: v3.5.0a4~45^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f4bbc535b9f6fdd5f4c32e0e5518bea371dd51fa;p=thirdparty%2FPython%2Fcpython.git #23925: stop (eg) PYTHONSTARTUP from causing test_cmd_line failure. Patch by Jamiel Almeida. --- diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 3683a48b7adc..cb9bbddc8c62 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -271,7 +271,11 @@ class CmdLineTest(unittest.TestCase): 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'],