Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
12424bc0
Commit
12424bc0
authored
May 23, 2002
by
Skip Montanaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
force gzip module to open files using 'b'inary mode.
closes patch #536278.
parent
d4e5be53
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
Lib/gzip.py
Lib/gzip.py
+4
-0
Lib/test/test_gzip.py
Lib/test/test_gzip.py
+5
-1
No files found.
Lib/gzip.py
View file @
12424bc0
...
...
@@ -35,6 +35,10 @@ class GzipFile:
def
__init__
(
self
,
filename
=
None
,
mode
=
None
,
compresslevel
=
9
,
fileobj
=
None
):
# guarantee the file is opened in binary mode on platforms
# that care about that sort of thing
if
mode
and
'b'
not
in
mode
:
mode
+=
'b'
if
fileobj
is
None
:
fileobj
=
self
.
myfileobj
=
__builtin__
.
open
(
filename
,
mode
or
'rb'
)
if
filename
is
None
:
...
...
Lib/test/test_gzip.py
View file @
12424bc0
...
...
@@ -18,7 +18,7 @@ data2 = """/* zlibmodule.c -- gzip-compatible data compression */
f
=
gzip
.
GzipFile
(
filename
,
'wb'
)
;
f
.
write
(
data1
*
50
)
;
f
.
close
()
f
=
gzip
.
GzipFile
(
filename
,
'r
b
'
)
;
d
=
f
.
read
()
;
f
.
close
()
f
=
gzip
.
GzipFile
(
filename
,
'r'
)
;
d
=
f
.
read
()
;
f
.
close
()
verify
(
d
==
data1
*
50
)
# Append to the previous file
...
...
@@ -75,4 +75,8 @@ for pos in range(0, 256, 16):
f
.
write
(
'GZ
\
n
'
)
f
.
close
()
f
=
gzip
.
GzipFile
(
filename
,
'r'
)
verify
(
f
.
myfileobj
.
mode
==
'rb'
)
f
.
close
()
os
.
unlink
(
filename
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment