New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
popen3 on windows loses environment variables #41436
Comments
see the following test code: #test_popen3_1.py
import os
FILENAME='c:\temp\test_popen3_2.py'
os.environ['FOOBAR']='foobar'
print os.environ['FOOBAR']
fs=os.popen3("c:\python24\python -u %s"%
FILENAME,'b')
print fs[1].read() #c:\temp\test_popen3_2.py Running test_popen3_1.py is expected to print out: But it doesn't print the last foobar. It correctly prints If the FILENAME is set to a relative path, as when you Tests run on windows XP, SP1. This bug is related to the cgi bug bpo-1100235. |
Logged In: YES Sorry. I got confused. When FILENAME is absolute, popen3 |
Logged In: YES I've tried recreating this problem and have had no luck. I've Any chance there's something special about how you are |
Logged In: YES Oh, stupid me. The full path filename included '\t'. It The real problem seems to be with os.environ. I have reassured this problem exists on some XP SP1 boxes. The test code is... #test_popen3_1.py
import os
FILENAME='test_popen3_2.py'
env={};env['ENVIRON_UPDATE']='123';os.environ.update(env)
os.environ['ENVIRON_DIRECT_SETTING']='123'
cmdline='c:\python24\python.exe -u %s'%FILENAME
fs=os.popen3(cmdline,'b')
print fs[1].read()
#test_popen3_2.py
import os
if os.environ.has_key('ENVIRON_UPDATE'):print 'os.env.update
worked'
else:print 'os.env.update failed'
if os.environ.has_key('ENVIRON_DIRECT_SETTING'):print
'os.env assignment worked'
else:print 'os.env assignment failed' Put these two files in the same path and run Following is the result I got: C:\test>\python23\python test_popen3_1.py C:\test>\python24\python test_popen3_1.py As you see the environment varaible that's updated with This is the reason CGIHTTPServer.py fails to deliver |
Logged In: YES Now I got it. The reason is os.py in python2.4 has changed To rectify the problem you just copy and paste the update --- os.py Thu Jan 27 07:09:38 2005
+++ os_new.py Thu Jan 27 07:10:44 2005
@@ -435,6 +435,9 @@
return key.upper() in self.data
def get(self, key, failobj=None):
return self.data.get(key.upper(), failobj)
+ def update(self, dict):
+ for k, v in dict.items():
+ self[k] = v
def copy(self):
return dict(self)
@@ -446,6 +449,9 @@
def __setitem__(self, key, item):
putenv(key, item)
self.data[key] = item
+ def update(self, dict):
+ for k, v in dict.items():
+ self[k] = v
try:
unsetenv
except NameError: |
Logged In: YES This was fixed in rev. 38397. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: