Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #48669

Re: os.putenv() has no effect

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 <python-python-list@m.gmane.org>
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 <tjreedy@udel.edu>
Subject Re: os.putenv() has no effect
Date Tue, 18 Jun 2013 16:31:35 -0400
References <kpq32r$cdc$1@news.albasani.net>
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 <kpq32r$cdc$1@news.albasani.net>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3558.1371587520.3114.python-list@python.org> (permalink)
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

Show key headers only | View raw


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:/sbin:~/bin'
>>>> os.putenv("PATH", "/")
>>>> os.getenv("PATH")
> '/usr/joebin:/usr/local/bin:/usr/bin:/bin:/usr/games/bin:/usr/sbin:/sbin:~/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 
os.environ are automatically translated into corresponding calls to 
putenv(); however, calls to putenv() don’t update os.environ, so it is 
actually preferable to assign to items of os.environ."

Also " Such changes to the environment affect subprocesses started with 
os.system(), popen() or fork() and execv()"

Not obvious fact: getenv gets values from the os.environ copy of the 
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] = value, which 
suggests that you did not read the full doc entry, which says to use the 
latter ;-).

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

os.putenv() has no effect Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-06-18 18:49 +0200
  Re: os.putenv() has no effect Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-06-18 19:48 +0200
  Re: os.putenv() has no effect inq1ltd <inq1ltd@inqvista.com> - 2013-06-18 13:24 -0400
  Re: os.putenv() has no effect Dave Angel <davea@davea.name> - 2013-06-18 14:09 -0400
    Re: os.putenv() has no effect Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-06-18 20:12 +0200
      Re: os.putenv() has no effect Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-06-18 20:16 +0200
  Re: os.putenv() has no effect Skip Montanaro <skip@pobox.com> - 2013-06-18 13:22 -0500
  Re: os.putenv() has no effect Terry Reedy <tjreedy@udel.edu> - 2013-06-18 16:31 -0400

csiph-web