mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-05 08:09:15 +00:00
Bug 1547730 - don't fail on an unsupported .seek() needed to support adding from compressed zipfile.ZipFile
entries. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D29216 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
6ae6eb968f
commit
82ebc9b565
@ -4,7 +4,10 @@
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
from io import BytesIO
|
||||
from io import (
|
||||
BytesIO,
|
||||
UnsupportedOperation,
|
||||
)
|
||||
import struct
|
||||
import subprocess
|
||||
import zlib
|
||||
@ -630,8 +633,10 @@ class JarWriter(object):
|
||||
if isinstance(data, (six.binary_type, six.string_types)):
|
||||
deflater.write(data)
|
||||
elif hasattr(data, 'read'):
|
||||
if hasattr(data, 'seek'):
|
||||
try:
|
||||
data.seek(0)
|
||||
except (UnsupportedOperation, AttributeError):
|
||||
pass
|
||||
deflater.write(data.read())
|
||||
else:
|
||||
raise JarWriterError("Don't know how to handle %s" %
|
||||
|
Loading…
x
Reference in New Issue
Block a user