Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove _fix_bad_spools #23

Open
shardros opened this issue Aug 17, 2022 · 0 comments
Open

Remove _fix_bad_spools #23

shardros opened this issue Aug 17, 2022 · 0 comments
Labels
bug Something isn't working dependencies Pull requests that update a dependency file

Comments

@shardros
Copy link
Member

shardros commented Aug 17, 2022

Due to a python bug not all of the interfaces are compatible.

The fastapi.UploadFile type inherits from SpooledTemporaryFile a builtin
which does not specify the abstract for IOBase and does not support the
seekable method which is required for writing to the file sys. There is
some work to fix this:

https://bugs.python.org/issue26175

A fix for this has been merged in into the 3.11 rc so hopefully this will be
fixed soon:

python/cpython@78e70be

For now we reach in to the object to try and patch it ourselves.
This will not work for files larger than UploadFile._max_size as the
attributes change:

https://stackoverflow.com/a/47169185/5006710

We make sure that the object has a large enough size in
increase_max_file_size

When 3.11 rolls out (and we are able to use it) _fix_bad_spools and
increase_max_file_size can be deleted.

@shardros shardros added bug Something isn't working dependencies Pull requests that update a dependency file labels Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

1 participant