This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: missing universal newline support in os.popen & friends
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, astrand, jackjansen, philiplindsay, shlomme
Priority: normal Keywords:

Created on 2003-08-13 13:17 by shlomme, last changed 2022-04-10 16:10 by admin. This issue is now closed.

Messages (7)
msg17731 - (view) Author: Torsten Marek (shlomme) Date: 2003-08-13 13:17
In contrast to the documentation, os.popen and relatives do not 
support the "U" format character in their constructors.

os.popen("some_nifty_command some_arg", "rU")
throws
OSError: [Errno 22] Invalid argument ,
while os.popen{2,3,4} just ignores "U".
I noticed that behaviour while p-opening oggenc (the ogg vorbis 
encoder), which uses curses for output. The lines end with \r and not 
with \n (due to some ncurses internals, I suspect), so that the file 
objects readline() function cannot split the output.
msg17732 - (view) Author: Jack Jansen (jackjansen) * (Python committer) Date: 2003-08-26 22:04
Logged In: YES 
user_id=45365

Theoretically this is easy to fix: if mode=="U" or "rU" just pass "r" 
to popen(), "rb" to fdopen() and _O_BINARY to the lowlevel calls, 
and the original string to PyFile_FromFile.

But this whole popen{,2,3,4} section of posixmodule.c is so 
fiendishly complicated with all the platform special cases that I'm 
loath to touch it...
msg17733 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2003-11-03 20:01
Logged In: YES 
user_id=344921

I've added universal newline support to popen5.
http://www.lysator.liu.se/~astrand/popen5/. 
msg17734 - (view) Author: Philip Lindsay (philiplindsay) Date: 2004-01-13 10:45
Logged In: YES 
user_id=254205

See
<http://advogato.org/person/follower/diary.html?start=43>
for details of a possible interim work around. (WFM, YMMV)
msg17735 - (view) Author: Philip Lindsay (philiplindsay) Date: 2004-01-13 10:46
Logged In: YES 
user_id=254205

See http://advogato.org/person/follower/diary.html?start=43
for details of a possible interim work around. (WFM, YMMV)
msg17736 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2006-08-03 20:50
Logged In: YES 
user_id=11375

popen5 was added to Python 2.4 as the subprocess module.

It's probably unlikely that someone will go back and fix the
low-level os.popen2() function.  I suggest that this bug be
closed, and we encourage people to use the subprocess module.
msg17737 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2006-08-05 17:33
Logged In: YES 
user_id=344921

Closing, as suggested by akuchling. 
History
Date User Action Args
2022-04-10 16:10:36adminsetgithub: 39056
2003-08-13 13:17:11shlommecreate