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
be66af42
Commit
be66af42
authored
Feb 12, 2012
by
Nadeem Vawda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up GzipFile mode string handling code.
parent
d1a10713
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
+5
-6
Lib/gzip.py
Lib/gzip.py
+5
-6
No files found.
Lib/gzip.py
View file @
be66af42
...
...
@@ -141,7 +141,7 @@ class GzipFile(io.BufferedIOBase):
"""
if
mode
and
(
't'
in
mode
or
'U'
in
mode
):
raise
IOError
(
"Mode "
+
mode
+
" not supported"
)
raise
ValueError
(
"Invalid mode: {!r}"
.
format
(
mode
)
)
if
mode
and
'b'
not
in
mode
:
mode
+=
'b'
if
fileobj
is
None
:
...
...
@@ -152,10 +152,9 @@ class GzipFile(io.BufferedIOBase):
else
:
filename
=
''
if
mode
is
None
:
if
hasattr
(
fileobj
,
'mode'
):
mode
=
fileobj
.
mode
else
:
mode
=
'rb'
mode
=
getattr
(
fileobj
,
'mode'
,
'rb'
)
if
mode
[
0
:
1
]
==
'r'
:
if
mode
.
startswith
(
'r'
)
:
self
.
mode
=
READ
# Set flag indicating start of a new member
self
.
_new_member
=
True
...
...
@@ -170,7 +169,7 @@ class GzipFile(io.BufferedIOBase):
self
.
min_readsize
=
100
fileobj
=
_PaddedFile
(
fileobj
)
elif
mode
[
0
:
1
]
==
'w'
or
mode
[
0
:
1
]
==
'a'
:
elif
mode
.
startswith
((
'w'
,
'a'
))
:
self
.
mode
=
WRITE
self
.
_init_write
(
filename
)
self
.
compress
=
zlib
.
compressobj
(
compresslevel
,
...
...
@@ -179,7 +178,7 @@ class GzipFile(io.BufferedIOBase):
zlib
.
DEF_MEM_LEVEL
,
0
)
else
:
raise
IOError
(
"Mode "
+
mode
+
" not supported"
)
raise
ValueError
(
"Invalid mode: {!r}"
.
format
(
mode
)
)
self
.
fileobj
=
fileobj
self
.
offset
=
0
...
...
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