All, I wanted to pass this one around before opening an issue on it. When running the unit test for popen via rt.bat (in PCBuild8), I received the following error:
=== BEGIN ERROR === C:\Documents and Settings\joe\Desktop\Development\Python\trunk\PCbuild8>rt test_popen Deleting .pyc/.pyo files ... 43 .pyc deleted, 0 .pyo deleted C:\Documents and Settings\joe\Desktop\Development\Python\trunk\PCbuild8>win32Release\python.exe -E -tt ../lib/test/regrtest.py te st_popen test_popen test test_popen failed -- Traceback (most recent call last): File "C:\Documents and Settings\joe\Desktop\Development\Python\trunk\lib\test\test_popen.py", line 31, in test_popen ["foo", "bar"] File "C:\Documents and Settings\joe\Desktop\Development\Python\trunk\lib\test\test_popen.py", line 24, in _do_test_commandline got = eval(data)[1:] # strip off argv[0] File "<string>", line 0 ^ SyntaxError: unexpected EOF while parsing 1 test failed: test_popen === END ERROR === Only naturally, I looked into what was causing it and noticed the following: Line 23 of the test_popen.py appears to be returning '' and assigning this to data. data = os.popen(cmd).read() The problem with is, the next line (24) assumes the previous line will work and goes on to perform the following strip and assert: got = eval(data)[1:] # strip off argv[0] self.assertEqual(got, expected) So, in a perfect world, ['-c','foo','bar']\n is what data Should be. I put some quick debug statements after line 23 in test_popen.py to verify this and I observed the following: data= cmd= "C:\Documents and Settings\joe\Desktop\Development\Python\trunk\PCbuild8\win32Release\python.exe" -c "import sys;print sys.argv" foo bar Now, on to the 'interesting' part. From the command line, observe the following: C:\Documents and Settings\joe\Desktop\Development\Python\trunk\PCbuild8\win32release>python -c "import sys; print sys.argv" foo bar ['-c', 'foo', 'bar'] Outside of the popen call failing. I am wondering if an appropriate assert should be performed on the data object, prior to line 24. In addition, if you debug into the posixmodule, this is the scoop: 1. breakpoint set in posixmodule at the start of posix_popen 2. i run in debug 3. run the following: import os tmp = os.popen('"C:/Documents and Settings/joe/Desktop/Development/Python/trunk/PCbuild8/win32Release/python.exe" -c "import sys;print sys.argv" foo bar') 3. call enters posixmodule posix_popen and follows path: f = _PyPopen(cmdstring, tm | _O_TEXT, POPEN_1); 4. enters posixmodule: _PyPopen 5. enters posixmodule: _PyPopenCreateProcess 6. enters posixmodule linen 4920 where the CreateProcess is... s2 checks out as: "C:\WINDOWS\system32\cmd.exe /c "C:/Documents and Settings/joe/Desktop/Development/Python/trunk/PCbuild8/win32Release/python.exe" -c "import sys;print sys.argv" foo bar" this call returns nonzero, which means it "succeeded". see: [ http://msdn2.microsoft.com/en-us/library/ms682425.aspx ] On another note, I ran across CreateProcessW and am interested in questioning whether or not this has a place in posixmodule? Any on yet another note, when I ran test_popen.py straight from /lib (using my std::Python25 install, I obtained the following debug output in the same statement of interest) data=['-c', 'foo', 'bar'] cmd=c:\python25\python.exe -c "import sys;print sys.argv" foo bar Your thoughts ? Joseph Armbruster _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com