[Patches] [ python-Patches-788404 ] ignore "b" and "t" mode modifiers in posix_popen

SourceForge.net noreply at sourceforge.net
Fri Oct 31 05:02:38 EST 2003


Patches item #788404, was opened at 2003-08-14 00:53
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=788404&group_id=5470

Category: Library (Lib)
Group: Python 2.3
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Andrew Gaul (gaul)
Assigned to: Martin v. Löwis (loewis)
Summary: ignore "b" and "t" mode modifiers in posix_popen

Initial Comment:
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').

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2003-10-31 11:02

Message:
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


----------------------------------------------------------------------

Comment By: Andrew Gaul (gaul)
Date: 2003-09-01 14:13

Message:
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.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2003-08-31 18:42

Message:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=788404&group_id=5470



More information about the Patches mailing list