If I call os.environ.clea r 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 2424
On Jun 27, 4:05*pm, "Joe P. Cool" <joe.p.c...@goo glemail.comwrot e:
If I call os.environ.clea r in a python program child processes still
see the deleted entries. But when I iterate over the keys like so
names = *os.environ.key s
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.comwro te:
> On Jun 27, 4:05*pm, "Joe P. Cool" <joe.p.c...@goo glemail.comwrot e:
>If I call os.environ.clea r in a python program child processes still see the deleted entries. But when I iterate over the keys like so
names = *os.environ.key s 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...@goo glemail.comwrot e:
If I call os.environ.clea r 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.key s' 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.key s()'.
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.cle ar()' or 'del os.environ[key]'?
On 28 Jun., 08:54, s0s...@gmail.co m wrote:
For one thing, the expression 'os.environ.key s' 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.key s()'.
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.cle ar()' 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.comwro te:
On Jun 27, 4:05 pm, "Joe P. Cool" <joe.p.c...@goo glemail.comwrot e:
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.clea r has no effect on child processes
--
Joe
On 28 Jun., 23:06, "Joe P. Cool" <joe.p.c...@goo glemail.comwrot e:
On 28 Jun., 04:05, Benjamin <musiccomposit. ..@gmail.comwro te:
On Jun 27, 4:05 pm, "Joe P. Cool" <joe.p.c...@goo glemail.comwrot e:
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.clea r 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.com wrote:
Benjamin <musiccomposit. ..@gmail.comwro te:
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
Properties"->Advanced->"Environment Variables". However, if I open a
console and type 'set', "SSID" is not listed; also if I open a python
shell and do os.environ the variable is not found. What am I
doing wrong???
import _winreg
|
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 display correct
web page.
|
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 to run my wiki/blog
software, Leonardo under Python 2.4 on Windows 2000. I was able to
reproduce the problem under Python 2.4 on Windows XP Pro but confirmed
that it worked fine under Python 2.3.
Simply printing out os.environ at the point...
|
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 =
os.path.join(os.environ, os.environ)?
If this was done, then modules such as pdb, which load resource files
from HOME, would work under Windows.
Alternatively, here is a patch to make pdb.py read .pdbrc under
Windows.
|
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 to check. What I
expected was that there would be minor code bloat and some speed
improvement when using templates. However...
I wrote a basic list container (using templates), and a list container
(using virtual derived classes). I also tried...
|
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 called "shrink_bs_070226" that looks like this:
**********************************
import sys, re, glob, shutil
import os
|
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? Does
anyone have any idea on this?
Thanks in advance!!!
|
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", "copyright", "credits" or "license" for more
information.
False
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |