[Patches] [ python-Patches-536278 ] force gzip to open files with 'b'
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 09 Apr 2002 09:30:06 -0700
Patches item #536278, was opened at 2002-03-28 08:53
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=536278&group_id=5470
Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Nobody/Anonymous (nobody)
Summary: force gzip to open files with 'b'
Initial Comment:
It doesn't make sense that the gzip module should
try to open a file in text mode. The attached
patch forces a 'b' into the file open mode if it
wasn't given. I also modified the test slightly to
try and tickle this code, but I can't test it very
effectively, because I don't do Windows... :-)
----------------------------------------------------------------------
>Comment By: Skip Montanaro (montanaro)
Date: 2002-04-09 11:30
Message:
Logged In: YES
user_id=44345
good point. updated patch.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-03-30 22:12
Message:
Logged In: YES
user_id=31435
I suggest fixing this via changing the test to
if mode and 'b' not in mode:
Then mode=None and mode='' will be left alone (as Neal
says, the code already does the right thing for those).
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2002-03-28 09:04
Message:
Logged In: YES
user_id=33168
There is a problem (sorry, I have an evil mind). :-)
If '' is passed as the mode, before the patch, this would
have been converted to 'rb'. After the patch, mode will
become 'b' and that will raise an exception:
>>> open('/dev/null', 'b')
IOError: [Errno 22] Invalid argument: b
If you add an (and mode) condition and that should be fine.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=536278&group_id=5470