mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
[3.11] gh-111841: Fix os.putenv() and os.unsetenv() with embedded NUL on Windows (GH-111842) (GH-111967)
(cherry picked from commit 0b06d2482d
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
7b55a955bc
commit
cd3e2d3a6c
4 changed files with 19 additions and 9 deletions
|
@ -1130,9 +1130,12 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
|
|||
def test_putenv_unsetenv_error(self):
|
||||
# Empty variable name is invalid.
|
||||
# "=" and null character are not allowed in a variable name.
|
||||
for name in ('', '=name', 'na=me', 'name=', 'name\0', 'na\0me'):
|
||||
for name in ('', '=name', 'na=me', 'name='):
|
||||
self.assertRaises((OSError, ValueError), os.putenv, name, "value")
|
||||
self.assertRaises((OSError, ValueError), os.unsetenv, name)
|
||||
for name in ('name\0', 'na\0me'):
|
||||
self.assertRaises(ValueError, os.putenv, name, "value")
|
||||
self.assertRaises(ValueError, os.unsetenv, name)
|
||||
|
||||
if sys.platform == "win32":
|
||||
# On Windows, an environment variable string ("name=value" string)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue