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
065f0c8a
Commit
065f0c8a
authored
Nov 12, 2006
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #1355023: support whence argument for GzipFile.seek.
parent
040a927c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
Lib/gzip.py
Lib/gzip.py
+6
-1
Lib/test/test_gzip.py
Lib/test/test_gzip.py
+11
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/gzip.py
View file @
065f0c8a
...
...
@@ -371,7 +371,12 @@ class GzipFile:
self
.
extrasize
=
0
self
.
offset
=
0
def
seek
(
self
,
offset
):
def
seek
(
self
,
offset
,
whence
=
0
):
if
whence
:
if
whence
==
1
:
offset
=
self
.
offset
+
offset
else
:
raise
ValueError
(
'Seek from end not supported'
)
if
self
.
mode
==
WRITE
:
if
offset
<
self
.
offset
:
raise
IOError
(
'Negative seek in write mode'
)
...
...
Lib/test/test_gzip.py
View file @
065f0c8a
...
...
@@ -128,6 +128,17 @@ class TestGzip(unittest.TestCase):
f
.
seek
(
newpos
)
# positive seek
f
.
close
()
def
test_seek_whence
(
self
):
self
.
test_write
()
# Try seek(whence=1), read test
f
=
gzip
.
GzipFile
(
self
.
filename
)
f
.
read
(
10
)
f
.
seek
(
10
,
whence
=
1
)
y
=
f
.
read
(
10
)
f
.
close
()
self
.
assertEquals
(
y
,
data1
[
20
:
30
])
def
test_seek_write
(
self
):
# Try seek, write test
f
=
gzip
.
GzipFile
(
self
.
filename
,
'w'
)
...
...
Misc/NEWS
View file @
065f0c8a
...
...
@@ -96,6 +96,8 @@ Core and builtins
Library
-------
- Patch #1355023: support whence argument for GzipFile.seek.
- Patch #1065257: Support passing open files as body in
HTTPConnection.request().
...
...
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