Path: csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'value,': 0.04; 'affected': 0.07; 'assign': 0.07; 'linux,': 0.07; 'latter': 0.09; 'preferable': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'supported,': 0.09; 'python': 0.11; 'bug': 0.12; 'jan': 0.12; 'changes': 0.15; 'assignments': 0.16; 'doc:': 0.16; 'os.environ': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:effect': 0.16; 'wrote:': 0.18; 'translated': 0.19; 'header:User-Agent:1': 0.23; 'environment': 0.24; "i've": 0.25; 'values': 0.27; 'gets': 0.27; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'url:bugs': 0.29; "doesn't": 0.30; '>>>>': 0.31; 'doc': 0.31; 'says': 0.33; 'url:python': 0.33; 'could': 0.34; 'anybody': 0.35; 'doing': 0.36; 'url:org': 0.36; 'application': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'affect': 0.61; 'full': 0.61; 'received:173': 0.61; 'such': 0.63; 'group,': 0.63; 'happen': 0.63; 'obvious': 0.74; 'entry,': 0.84; 'received:fios.verizon.net': 0.84; 'don\xe2\x80\x99t': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: os.putenv() has no effect Date: Tue, 18 Jun 2013 16:31:35 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371587520 news.xs4all.nl 16004 [2001:888:2000:d::a6]:51690 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48669 On 6/18/2013 12:49 PM, Johannes Bauer wrote: > Hi group, > > I've tracked down a bug in my application to a rather strange > phaenomenon: os.putenv() doesn't seem to have any effect on my platform= > (x86-64 Gentoo Linux, Python 3.2.3): > >>>> os.getenv("PATH") > '/usr/joebin:/usr/local/bin:/usr/bin:/bin:/usr/games/bin:/usr/sbin:/sbi= n:~/bin' >>>> os.putenv("PATH", "/") >>>> os.getenv("PATH") > '/usr/joebin:/usr/local/bin:/usr/bin:/bin:/usr/games/bin:/usr/sbin:/sbi= n:~/bin' > > >>>> os.getenv("FOO") >>>> os.putenv("FOO", "BAR") >>>> os.getenv("FOO") >>>> > > Does anybody know why this would happen From the doc: "When putenv() is supported, assignments to items in=20 os.environ are automatically translated into corresponding calls to=20 putenv(); however, calls to putenv() don=E2=80=99t update os.environ, so = it is=20 actually preferable to assign to items of os.environ." Also " Such changes to the environment affect subprocesses started with=20 os.system(), popen() or fork() and execv()" Not obvious fact: getenv gets values from the os.environ copy of the=20 environment, which is not affected by putenv. See http://bugs.python.org/issue1159 > or what I could be doing wrong? Using putenv(key, value) instead of os.environ[key] =3D value, which=20 suggests that you did not read the full doc entry, which says to use the = latter ;-). --=20 Terry Jan Reedy