summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-12-31 19:15:26 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-12-31 19:15:26 (GMT)
commita617271dbd150549b021a5161d009869ad62f7b2 (patch)
tree764221870afed35cab4c4bc8e07d31964a794fc4 /Lib/tarfile.py
parent54266fce8db4c303a2c5ae84ecd0db493b400625 (diff)
downloadcpython-a617271dbd150549b021a5161d009869ad62f7b2.zip
cpython-a617271dbd150549b021a5161d009869ad62f7b2.tar.gz
cpython-a617271dbd150549b021a5161d009869ad62f7b2.tar.bz2
Use cStringIO where available.
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r--Lib/tarfile.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index b85f117..0dc7a42 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1936,12 +1936,15 @@ class TarFileCompat:
def write(self, filename, arcname=None, compress_type=None):
self.tarfile.add(filename, arcname)
def writestr(self, zinfo, bytes):
- import StringIO
+ try:
+ from cStringIO import StringIO
+ except ImportError:
+ from StringIO import StringIO
import calendar
zinfo.name = zinfo.filename
zinfo.size = zinfo.file_size
zinfo.mtime = calendar.timegm(zinfo.date_time)
- self.tarfile.addfile(zinfo, StringIO.StringIO(bytes))
+ self.tarfile.addfile(zinfo, StringIO(bytes))
def close(self):
self.tarfile.close()
#class TarFileCompat