Bugs item #1101667, was opened at 2005-01-13 23:33 Message generated for change (Comment added) made by juneaftn You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1101667&group_id=5470
Category: Python Library Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: June Kim (juneaftn) Assigned to: Nobody/Anonymous (nobody) Summary: popen3 on windows loses environment variables Initial Comment: 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 print "from test_popen3_2.py" import os;print os.environ['FOOBAR'] Running test_popen3_1.py is expected to print out: foobar from test_popen3_2.py foobar But it doesn't print the last foobar. It correctly prints out when run on python 2.3. If the FILENAME is set to a relative path, as when you are in the c:\temp directory and the FILENAME is set to test_popen3_2.py, the code works correct. Tests run on windows XP, SP1. This bug is related to the cgi bug #1100235. ---------------------------------------------------------------------- >Comment By: June Kim (juneaftn) Date: 2005-01-27 16:00 Message: Logged In: YES user_id=116941 Oh, stupid me. The full path filename included '\t'. It should've been escaped. Then the example code works with 2.3 and 2.4. 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 test_popen3_1.py with python2.4 and python2.3. Following is the result I got: C:\test>\python23\python test_popen3_1.py os.env.update worked os.env assignment worked C:\test>\python24\python test_popen3_1.py os.env.update failed os.env assignment worked As you see the environment varaible that's updated with os.environ.update has failed to get passed to popen3ed process. This is the reason CGIHTTPServer.py fails to deliver QUERY_STRING and etc. -- they are updated with os.environ.update(env). ---------------------------------------------------------------------- Comment By: AGunn (ompeag) Date: 2005-01-27 06:21 Message: Logged In: YES user_id=1155133 I've tried recreating this problem and have had no luck. I've tried three versions of python: 2.3, 2.4, and the current build version (2.5 something?). I've also tried both absolute and relative paths. All tests print out the second 'foobar' just fine. I, too, am running XP, SP1. Any chance there's something special about how you are running the executables? Say from a cygwin environment or something? ---------------------------------------------------------------------- Comment By: June Kim (juneaftn) Date: 2005-01-13 23:36 Message: Logged In: YES user_id=116941 Sorry. I got confused. When FILENAME is absolute, popen3 loses the environment variables, whereas it is relative, popen3 works fine. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1101667&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com