STINNER Victor <victor.stin...@haypocalc.com> added the comment:

> But... there is no os.unsetenv on Windows!

Correct, even unsetenv() doesn't exist on Windows: putenv() can be used to 
unset a variable using an empty value. And it's exactly what Python does.

It is confusing because posix_unsetenv() is not build on Windows, but it 
contains code specific for Windows.

While testing del os.environ[key], I found another bug: del 
os.environ['x'*50000] does crash Python on Windows.

Attached patch (for Python 3.3) does:

 - Remove the Windows specific code from posix_unsetenv()
 - Check if unsetenv() failed on UNIX
 - Check environment variable length on Windows

The Windows bug does affect Python 2.7 too. "Check if unsetenv() failed on 
UNIX" change may be skipped on Python 2.7 and 3.2.

----------
keywords: +patch
title: os.unsetenv() on Windows should not use UTF-8 -> del os.environ[key] 
ignores errors
versions: +Python 2.7
Added file: http://bugs.python.org/file23714/unsetenv.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13415>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to