Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
Replace StringIO with ByteIO
Browse files Browse the repository at this point in the history
Flask on python3 won't work with StringIO as send_file only expects to be given binary file-like objects and it wouldn't know how to encode the string to bytes, according to issue #3358 in Flask repo

Signed-off-by: SolidifiedRay <[email protected]>
  • Loading branch information
SolidifiedRay committed Jul 9, 2020
1 parent c866de6 commit cbd240c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import os
import uuid
import time
import StringIO
import io
import tarfile

from functools import wraps
Expand Down Expand Up @@ -1044,8 +1044,8 @@ def download_layout():
layout_metadata = in_toto.models.metadata.Metablock(signed=layout)

# Dump layout to memory file and server to user
layout_fp = StringIO.StringIO()
layout_fp.write("{}".format(layout_metadata))
layout_fp = io.BytesIO()
layout_fp.write(("{}".format(layout_metadata)).encode())
layout_fp.seek(0)
return send_file(layout_fp,
mimetype="application/json", as_attachment=True,
Expand Down

0 comments on commit cbd240c

Please sign in to comment.