mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Use cStringIO where available.
This commit is contained in:
parent
54266fce8d
commit
a617271dbd
8 changed files with 55 additions and 19 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue