summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2012-01-03 04:26:13 (GMT)
committerEli Bendersky <eliben@gmail.com>2012-01-03 04:26:13 (GMT)
commit74c503b40d9c40b1a5e7874188f36e067b14356c (patch)
tree98c491d186343d3a079621c16d3c5a6d08c1cd6f /Lib/tarfile.py
parentc041ab6c7d8fb6c32499c7adbe36bb9b48228c2c (diff)
downloadcpython-74c503b40d9c40b1a5e7874188f36e067b14356c.zip
cpython-74c503b40d9c40b1a5e7874188f36e067b14356c.tar.gz
cpython-74c503b40d9c40b1a5e7874188f36e067b14356c.tar.bz2
use io.SEEK_* constants instead of os.SEEK_* where an IO stream is seeked, leaving the os.SEEK_* constants only for os.lseek, as documented
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r--Lib/tarfile.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 39dc1f1..427f132 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -40,6 +40,7 @@ __credits__ = "Gustavo Niemeyer, Niels Gust\u00e4bel, Richard Townsend."
#---------
import sys
import os
+import io
import shutil
import stat
import time
@@ -833,20 +834,20 @@ class ExFileObject(object):
return self.position
- def seek(self, pos, whence=os.SEEK_SET):
+ def seek(self, pos, whence=io.SEEK_SET):
"""Seek to a position in the file.
"""
if self.closed:
raise ValueError("I/O operation on closed file")
- if whence == os.SEEK_SET:
+ if whence == io.SEEK_SET:
self.position = min(max(pos, 0), self.size)
- elif whence == os.SEEK_CUR:
+ elif whence == io.SEEK_CUR:
if pos < 0:
self.position = max(self.position + pos, 0)
else:
self.position = min(self.position + pos, self.size)
- elif whence == os.SEEK_END:
+ elif whence == io.SEEK_END:
self.position = max(min(self.size + pos, self.size), 0)
else:
raise ValueError("Invalid argument")