[issue26175] Fully implement IOBase abstract on SpooledTemporaryFile

Antti Haapala report at bugs.python.org
Fri Oct 30 08:51:51 EDT 2020


Antti Haapala <antti at haapala.name> added the comment:

Another test case:

import tempfile
import io
import json


with tempfile.SpooledTemporaryFile(max_size=2**20) as f:
    tf = io.TextIOWrapper(f, encoding='utf-8')
    json.dump({}, fp=tf)

I was writing json to a file-like object that I need to read in as binary (to upload to S3). Originally the code used BytesIO and I thought it would be wise to actually spool this to disk as I was operating with possible limited RAM... except that of course it didn't work.

----------
nosy: +ztane

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue26175>
_______________________________________


More information about the Python-bugs-list mailing list