[2.7] bpo-30746: Prohibited the '=' character in environment variable names (GH-2382) (#2393)
in `os.putenv()` and `os.spawn*()`..
(cherry picked from commit 77703942c5997dff00c48f10df1b29b11645624c)
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index e0c84f2..f1626b7 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -504,6 +504,15 @@
finally:
posix.lchflags(_DUMMY_SYMLINK, dummy_symlink_st.st_flags)
+ @unittest.skipUnless(hasattr(os, "putenv"), "requires os.putenv()")
+ def test_putenv(self):
+ with self.assertRaises(TypeError):
+ os.putenv('FRUIT\0VEGETABLE', 'cabbage')
+ with self.assertRaises(TypeError):
+ os.putenv('FRUIT', 'orange\0VEGETABLE=cabbage')
+ with self.assertRaises(ValueError):
+ os.putenv('FRUIT=ORANGE', 'lemon')
+
@unittest.skipUnless(hasattr(posix, 'getcwd'),
'test needs posix.getcwd()')
def test_getcwd_long_pathnames(self):