[issue1159] os.getenv() not updated after external module uses C putenv()

Raghuram Devarakonda report at bugs.python.org
Thu Sep 13 19:58:13 CEST 2007


Raghuram Devarakonda added the comment:

> Stefan Sonnenberg-Carstens added the comment:
>
> > As per the document and my simple test (on Linux), os.putenv() does
> > not update os.environ. I think, it should update it.
> What would be the benefit ?

Symmetrical behaviour. When os.getenv() returns the value from
os.environ, one would expect, os.putenv to store the value there (At
least, I did). On the other hand, it is also ok for both os.getenv and
os.putenv get/set the environment directly instead of going through
os.environ. I am sure there was some reason for the current behaviour
of os.putenv. Perhaps, because putenv is supposedly not available on
all platforms?

Any way, I think the OP was asking to always "get" the value
dynamically when ever os.environ['VAR'] or os.getenv['VAR'] is done. I
don't see any problem with that approach. How ever, if it is
considered backwards incompatible, I guess an optional parameter can
be added to os.getenv.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1159>
__________________________________


More information about the Python-bugs-list mailing list