I have a function unzip written in Python2.7
def unzip(text):
try:
return gzip.GzipFile(fileobj=StringIO(text)).read()
except IOError:
return text
When ran with Python3.7, I'm getting an error
TypeError: can't concat str to bytes
I tried
changing it to return gzip.GzipFile(fileobj=bytes(text, 'utf-8')).read()
But then I got: AttributeError: 'bytes' object has no attribute 'read'