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 robert.ancell
Recipients draghuram, loewis, pythonmeister, robert.ancell
Date 2007-09-14.00:20:26
SpamBayes Score 0.01505945
Marked as misclassified No
Message-id <1189729226.92.0.154996544042.issue1159@psf.upfronthosting.co.za>
In-reply-to
Content
draghuram, unfortunately while os.putenv() can be fixed to be
symmetrical any putenv call from a C module cannot, for example:

If you make an extension:
#include <stdlib.h>
PyObject *putenvC(PyObject *module, PyObject *args)
{
    int result;

    if (!PyArg_ParseTuple(args, ""))
        return 0;

    result = putenv("FOO=BAR");

    return Py_BuildValue("i", result);
}

The following behaviour will occur:
$ python
>>> import putenv
>>> putenv.putenvC()
>>> assert(os.getenv('FOO') == None)
>>> assert(os.environ.get('FOO') == None)

This is because the os.environ dictionary will never be updated:
From Lib/os.py:
def getenv(key, default=None):
    """Get an environment variable, return None if it doesn't exist.
    The optional second argument can specify an alternate default."""
    return environ.get(key, default)
History
Date User Action Args
2007-09-14 00:20:27robert.ancellsetspambayes_score: 0.0150594 -> 0.01505945
recipients: + robert.ancell, loewis, draghuram, pythonmeister
2007-09-14 00:20:26robert.ancellsetspambayes_score: 0.0150594 -> 0.0150594
messageid: <1189729226.92.0.154996544042.issue1159@psf.upfronthosting.co.za>
2007-09-14 00:20:26robert.ancelllinkissue1159 messages
2007-09-14 00:20:26robert.ancellcreate