If I call os.environ.clear in a python program child processes still
see the deleted entries. But when I iterate over the keys like so
names = os.environ.keys
for k in names:
del os.environ[k]
then the entries are also deleted for the child processes. Where is
the difference? Is this a bug?
(Observed in Python 2.5.2)
--
Joe 7 2342
On Jun 27, 4:05*pm, "Joe P. Cool" <joe.p.c...@googlemail.comwrote:
If I call os.environ.clear in a python program child processes still
see the deleted entries. But when I iterate over the keys like so
names = *os.environ.keys
for k in names:
* * del *os.environ[k]
then the entries are also deleted for the child processes. Where is
the difference? Is this a bug?
(Observed in Python 2.5.2)
This is because of how os.environ is implement with a UserDict
subclass. You should report this at bugs.python.org.
>
--
Joe
Benjamin <mu**************@gmail.comwrote:
> On Jun 27, 4:05*pm, "Joe P. Cool" <joe.p.c...@googlemail.comwrote:
>If I call os.environ.clear in a python program child processes still see the deleted entries. But when I iterate over the keys like so
names = *os.environ.keys for k in names: * * del *os.environ[k]
then the entries are also deleted for the child processes. Where is the difference? Is this a bug? (Observed in Python 2.5.2)
This is because of how os.environ is implement with a UserDict subclass.
Why? I mean, I can see that it happens, but I don't understand why being a
UserDict causes this.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
On Jun 27, 4:05 pm, "Joe P. Cool" <joe.p.c...@googlemail.comwrote:
If I call os.environ.clear in a python program child processes still
see the deleted entries. But when I iterate over the keys like so
names = os.environ.keys
for k in names:
del os.environ[k]
then the entries are also deleted for the child processes. Where is
the difference? Is this a bug?
(Observed in Python 2.5.2)
For one thing, the expression 'os.environ.keys' will yield a method
object (not a list, as you're probably expecting), but iterating over
a method as you did should produce an exception. If you want to get
the list of environment vars, you have to call the method, like
'os.environ.keys()'.
Also, aren't changes to environment vars supposed to be visible to
child processes anyway? Which one are you suggesting that behaves the
wrong way, 'os.environ.clear()' or 'del os.environ[key]'?
On 28 Jun., 08:54, s0s...@gmail.com wrote:
For one thing, the expression 'os.environ.keys' will yield a method
object (not a list, as you're probably expecting), but iterating over
a method as you did should produce an exception. If you want to get
the list of environment vars, you have to call the method, like
'os.environ.keys()'.
You are right but it's just a typo in this message, sorry. My real
code is correct.
Also, aren't changes to environment vars supposed to be visible to
child processes anyway?
Yes. Both the clear method and the del method change os.environ.
os.environ IS the environment in a python program.
Which one are you suggesting that behaves the
wrong way, 'os.environ.clear()' or 'del os.environ[key]'?
The former. If a key is not in os.environ, it shouldn't exist for
child
processes.
On 28 Jun., 04:05, Benjamin <musiccomposit...@gmail.comwrote:
On Jun 27, 4:05 pm, "Joe P. Cool" <joe.p.c...@googlemail.comwrote:
This is because of how os.environ is implement with a UserDict
subclass. You should report this at bugs.python.org.
issue 3227: os.environ.clear has no effect on child processes
--
Joe
On 28 Jun., 23:06, "Joe P. Cool" <joe.p.c...@googlemail.comwrote:
On 28 Jun., 04:05, Benjamin <musiccomposit...@gmail.comwrote:
On Jun 27, 4:05 pm, "Joe P. Cool" <joe.p.c...@googlemail.comwrote:
This is because of how os.environ is implement with a UserDict
subclass. You should report this at bugs.python.org.
issue 3227: os.environ.clear has no effect on child processes.
According to Benjamin Peterson this has been fixed in the upcoming
Python 2.6.
On Jun 28, 1:23*am, Tim Roberts <t...@probo.comwrote:
Benjamin <musiccomposit...@gmail.comwrote:
This is because of how os.environ is implement with a UserDict
subclass.
Why? *I mean, I can see that it happens, but I don't understand why being a
UserDict causes this.
The contents of a UserDict is stored in UserDict.data. When
UserDict.clear is called, that contents is simply cleared. environ
needs to override this is to unset env variable and then update the
actual dict.
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Erick Bodine |
last post by:
I am trying to set a new environment variable on a W2k machine with
only partial success. The name("SSID") and value("ASIM") show up
correctly in the registry and when I go to "System...
|
by: mahongquan |
last post by:
when i install moinmoin in python 2.4,windows server2000, I found it has a
bug,cgiHttpServer.py set environ,but the cgi python script can not get the
environ variant,such as environ,so moin donot...
|
by: jtauber |
last post by:
Did something change between 2.3 and 2.4 that would affect os.environ
being populated with CGI variables when using the
BaseHTTPServer/CGIHTTPServer?
I received a bug report from someone trying...
|
by: jim.eggleston |
last post by:
Windows doesn't have a HOME environment variable, but it does have
HOMEDRIVE and HOMEPATH. Could Windows versions of Python automatically
populate os.environ with HOME, where HOME =...
|
by: codergem |
last post by:
Hello Friends
Can anyone help me where exactly at what address the *p is storing the
updated value ( which is 99).
const int k=9;
int *p=(int *)&k;
cout<<"Addr of k : "<<&k<<" "<<p;
|
by: charles.lobo |
last post by:
Hi,
I have recently begun using templates in C++ and have found it to be
quite useful. However, hearing stories of code bloat and assorted
problems I decided to write a couple of small programs...
|
by: boris.smirnov |
last post by:
Hi there,
I have a problem with setting environment variable in my script that
uses qt library. For this library I have to define a path to tell the
script whre to find it.
I have a script...
|
by: Rahul |
last post by:
Hi Everyone,
I once had a look at a code having the following declaration,
extern ** environ or extern char ** environ...
I lost the code and i'm wondering what is the exact need of this?...
|
by: Tim Chase |
last post by:
Not sure what's going on here and hoping for some insight:
tim@rubbish:~$ echo $COLUMNS
129
tim@rubbish:~$ python2.5
Python 2.5.2 (r252:60911, May 28 2008, 08:35:32)
on linux2
Type "help",...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
header("Location:".$urlback);
Is this the right layout the...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
| |