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: ignore "b" and "t" mode modifiers in posix_popen
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: loewis Nosy List: gaul, loewis
Priority: normal Keywords: patch

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

Files
File name Uploaded Description Edit
popen_bt.diff gaul, 2003-08-13 22:53 ignore "b" and "t" mode modifiers in posix_popen
popen_bt2.diff gaul, 2003-09-01 12:13 ignore "b" and "t" mode modifiers in posix_popen, again
Messages (4)
msg44449 - (view) Author: Andrew Gaul (gaul) Date: 2003-08-13 22:53
Fixes bug 703198.  This patch removes any "b" or "t"
modifiers, which have meaning in Windows (binary and
text modes, respectively), but not in POSIX.  This
allows users to write portable code between Windows and
POSIX when working on binary data in pipes:
os.popen(cmd, 'rb').
msg44450 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-08-31 16:42
Logged In: YES 
user_id=21627

Maybe I'm mistaken: Does this patch really modify the string
object that is being passed? This would not be good: strings
are immutable.
msg44451 - (view) Author: Andrew Gaul (gaul) Date: 2003-09-01 12:13
Logged In: YES 
user_id=139865

*puzzles over why patch is so backward*  Yes, it modifies an
immutable object - double plus ungood.  Attached is a
simpler patch which does the right thing.  Sorry, I do not
know what was going through my head at the time.  My best
guess was that I thought that mode was a safe, mutable copy
of the immutable Python string and I wanted to allow modes
like "br", which the MSDN docs actually say are invalid ('b'
and 't' modifiers must be appended).

Note that the behaviour of POSIX posix_popen in this patch
differs from Windows posix_popen, as the latter allows
treats "rw", "r+", and "rr" as "r".  In all three cases,
POSIX systems throw "OSError: [Errno 22] Invalid argument"
at pipe creation.  In the case of "rw", Windows systems
throw "IOError: [Errno 9] Bad file descriptor" when the
read-only pipe is first written to.  Ideally, Windows
posix_popen should be modified to the new POSIX behaviour to
give earlier error reporting.
msg44452 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-10-31 10:02
Logged In: YES 
user_id=21627

Thanks for the patch. Applied as

NEWS 1.831.4.70
posixmodule.c 2.300.8.4
posixmodule.c 2.307
History
Date User Action Args
2022-04-10 16:10:38adminsetgithub: 39061
2003-08-13 22:53:44gaulcreate