[ python-Bugs-996748 ] os.environ documentation should indicate unreliability

SourceForge.net noreply at sourceforge.net
Sun Jul 25 19:52:22 CEST 2004


Bugs item #996748, was opened at 2004-07-23 20:41
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=996748&group_id=5470

Category: Python Library
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Richard Tibbetts (tibbetts)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.environ documentation should indicate unreliability

Initial Comment:
Looking at the documenation for the os module, nothing
in the documentation of os.environ would indicate that
it is unreliable. But then looking at os.putenv, we see
that os.environ will not reflect changes made to the
environment through other means.

To me, this makes os.environ much less useful. In fact,
it makes it somewhat harmful. I would argue for
deprecating it, or at least documenting this problem.

Thanks,
Richard


----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2004-07-25 19:52

Message:
Logged In: YES 
user_id=21627

rhettinger: why are you saying that putenv does not modify
the current environment? According to

http://www.opengroup.org/onlinepubs/009695399/functions/putenv.html

it does modify the current environment; more specifically,
it modifies environ.

tibbetts, can you please explain what other means of
modifying the environment may occur? In a Python program,
the only way of modifying the environment is through
modifying os.environ, which calls putenv, or through
directly using putenv. If anything should be changed, we
should advise people not to call putenv directly.


----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-07-24 22:25

Message:
Logged In: YES 
user_id=80475

FWIW, os.environ is reliable; it is putenv that is not doing
what you expect.

putenv() is there for updating the environment of
sub-processes. There doesn't appear to be a reliable cross
platform approach having any program update its own environment.

Look on ASPN for my recipe that shows an o.s. trick for
solving this problem.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=996748&group_id=5470


More information about the Python-bugs-list mailing list