[New-bugs-announce] [issue1159] os.getenv() not updated after external module uses C putenv()
Robert Ancell
report at bugs.python.org
Thu Sep 13 09:22:07 CEST 2007
New submission from Robert Ancell:
The Python os.getenv() function accesses an Python dictionary which is
mirroring the process environment. This dictionary is populated when the
interpreter starts and updated when os.environ.__setitem__() or
os.putenv() are called. However if the python program imports an
extension module that uses the system putenv() then the changes cannot
be accessed using the Python standard library.
This has been a problem for us as we have created Python bindings to an
existing C based library that modifies the environment dynamically (not
the best design decision...). The workaround we are using is to create
our own wrapper to the system (Solaris/Linux) getenv().
A potential solution could be to make environ a class where
os.environ.__setitem__() calls putenv(), os.environ.__getitem__() calls
getenv() and os.environ.keys()/items()/iter*() uses **environ (or other
appropriate system call). This does however have undefined issues on how
the environment behaves on various systems (memory leaks etc).
----------
components: Library (Lib)
messages: 55881
nosy: robert.ancell
severity: normal
status: open
title: os.getenv() not updated after external module uses C putenv()
type: behavior
versions: Python 2.6
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1159>
__________________________________
More information about the New-bugs-announce
mailing list