This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author baikie
Recipients BreamoreBoy, amaury.forgeotdarc, baikie, ggenellina, loewis
Date 2010-07-24.19:20:30
SpamBayes Score 6.387822e-07
Marked as misclassified No
Message-id <1279999234.24.0.262162548665.issue4926@psf.upfronthosting.co.za>
In-reply-to
Content
Unit tests were in the patch!  However, none of the patches
applied any more, so I've updated them and also improved the
tests a bit.  Again, I haven't tried them on Windows.

Unsetting a nonexistent variable isn't supposed to be an error
(see POSIX), but I did find a different problem with checking
unsetenv()'s return value, which is that older systems declare it
as void.  I've removed the check from the patch, mainly because I
don't know how to write the appropriate autoconf test, but it
isn't strictly necessary as long as putenv() can't set a name
that unsetenv() can fail to remove.

I did however find one more case where that can happen, which is
with an environment variable that has an empty name.  Linux at
least allows such variables to be set and passed to new
processes, but its unsetenv() will not remove them - the latter
behaviour is required by POSIX.

To avoid a use-after-free problem similar to the embedded-'='
one, I've made a separate patch to make putenv() raise ValueError
for empty names as well, but it's a more awkward case as Python
may receive such a variable on startup, which it would then be
unable to change (although even without the patch, it's already
unable to remove it - posix.unsetenv() just silently fails).

Checking unsetenv()'s return value would avoid the use-after-free
without having to change putenv(), but it would, for example,
make os.environ.clear() fail if an empty-named variable was
present - which would be correct, since the variable was not
removed, but rather surprising.  To really delete such a variable
would require editing **environ directly, AFAIK.
History
Date User Action Args
2010-07-24 19:20:34baikiesetrecipients: + baikie, loewis, amaury.forgeotdarc, ggenellina, BreamoreBoy
2010-07-24 19:20:34baikiesetmessageid: <1279999234.24.0.262162548665.issue4926@psf.upfronthosting.co.za>
2010-07-24 19:20:32baikielinkissue4926 messages
2010-07-24 19:20:31baikiecreate