Issue 5329: os.popen2 and os.popen3 in python 2.6 incompatible with os.popen* in python 2.5 (original) (raw)

Created on 2009-02-20 09:14 by jahakala, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
os-popen.diff jahakala,2009-02-20 11:12 Lib/os.py fix against release26-maint
os-popen-list.patch exarkun,2009-08-27 16:43 Unit tests for os.popen2, os.popen3, and os.popen4 with a list instead of a string
subprocess-conversion-doc.patch exarkun,2009-09-05 15:12 update the docs for converting from os.popen* to subprocess.Popen
subprocess-conversion-doc2.patch pjenvey,2009-09-29 17:17
Messages (11)
msg82523 - (view) Author: Jani Hakala (jahakala) Date: 2009-02-20 09:14
The implementation in python 2.6 expects the cmd argument to be a string. The documentation - help(os.popen3) - states that the cmd argument can be a sequence on Unix. This difference may cause programs that work with python 2.5 to fail with python 2.6 I have tested the patch attached with one of my scripts that failed with python 2.6 and the fix appears to work.
msg82567 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-02-21 14:24
Adding a couple of unit tests would be nice.
msg90259 - (view) Author: Max Bowsher (maxb) Date: 2009-07-08 08:15
With or without tests, this is a regression from Python 2.5 - shouldn't something be done about that?
msg90266 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-07-08 13:22
The test is the proof the the regression, and shows the change in behavior and the purpose of the development. There happens to be a test for os.popen3 (in Lib/test/test_popen2.py) which passes a list; this one at least passes. os.popen3() accepts a sequence, except that since 2.6, the first item is the whole command string, and additional items are treated as additional shell arguments! Your patch is correct. A unit test could be: w, r, e = os.popen3(['echo', 'hello']) assert r.read() == 'hello\n' And should be disabled on non-posix platforms.
msg92008 - (view) Author: Jean-Paul Calderone (exarkun) * (Python committer) Date: 2009-08-27 16:44
Attached os-popen-list.patch which includes all of the earlier os-popen.diff and adds tests which fail without this patch and pass with it. They also pass on Python 2.5. The patch is against the Python 2.6 maintenance branch, but presumably it should be applied to trunk as well.
msg92227 - (view) Author: Philip Jenvey (pjenvey) * (Python committer) Date: 2009-09-04 02:37
The subprocess docs (in Doc/library/subprocess.rst and the module itself) need to also reflect this change
msg92228 - (view) Author: Jean-Paul Calderone (exarkun) * (Python committer) Date: 2009-09-04 02:51
Hey Philip, I'm not sure I follow. The patch only changes the os module, not the subprocess module. What subprocess documentation do you think needs to be updated?
msg92229 - (view) Author: Philip Jenvey (pjenvey) * (Python committer) Date: 2009-09-04 02:59
Sorry, I meant the docs describing how to convert os.popen* calls to subprocess calls. They assume the shell arg is always True regardless of the cmd arg type. Those docs are probably the original source of this bug
msg92279 - (view) Author: Jean-Paul Calderone (exarkun) * (Python committer) Date: 2009-09-05 15:13
Ah, thanks for the clarification, Philip. I've attached another patch updating those docs.
msg93304 - (view) Author: Philip Jenvey (pjenvey) * (Python committer) Date: 2009-09-29 17:17
Here's the doc change with a lil more clarification, and I've also applied it to the module's own docs
msg93318 - (view) Author: Philip Jenvey (pjenvey) * (Python committer) Date: 2009-09-29 19:19
applied in r75143/r75144, in time for 2.6.3. thanks!
History
Date User Action Args
2022-04-11 14:56:45 admin set github: 49579
2009-09-29 19:19:57 pjenvey set status: open -> closedresolution: accepted -> fixedmessages: +
2009-09-29 18:49:15 barry set keywords: - needs reviewassignee: pjenveyresolution: accepted
2009-09-29 17:17:27 pjenvey set files: + subprocess-conversion-doc2.patchmessages: +
2009-09-05 15:13:17 exarkun set messages: +
2009-09-05 15:12:49 exarkun set files: + subprocess-conversion-doc.patch
2009-09-04 02:59:43 pjenvey set messages: +
2009-09-04 02:51:17 exarkun set messages: +
2009-09-04 02:37:33 pjenvey set nosy: + pjenveymessages: +
2009-08-27 16:44:57 exarkun set nosy: + exarkunmessages: +
2009-08-27 16:43:13 exarkun set files: + os-popen-list.patch
2009-07-08 13:22:05 amaury.forgeotdarc set keywords: + needs reviewnosy: + amaury.forgeotdarcmessages: +
2009-07-08 08:15:09 maxb set messages: +
2009-07-08 08:12:41 maxb set nosy: + maxb
2009-02-21 14:24:44 pitrou set priority: highnosy: + pitroumessages: + versions: + Python 2.7
2009-02-20 11:13:01 jahakala set files: - os-popen.diff
2009-02-20 11:12:38 jahakala set files: + os-popen.diff
2009-02-20 09:35:11 jahakala set type: behavior
2009-02-20 09:14:02 jahakala create