Skip to content

fix spooled temporary file exceptions on file upload - 2#1409

Merged
davidism merged 2 commits into
pallets:masterfrom
uncojohnco:1344-SpooledTemporaryFile-exceptions-on-file-upload-v2
Dec 3, 2018
Merged

fix spooled temporary file exceptions on file upload - 2#1409
davidism merged 2 commits into
pallets:masterfrom
uncojohnco:1344-SpooledTemporaryFile-exceptions-on-file-upload-v2

Conversation

@uncojohnco

@uncojohnco uncojohnco commented Nov 30, 2018

Copy link
Copy Markdown

Changed behaviour of FileStorage.__getattr__ so that when there is an exception AttributeError to attempt to call the FileStorage.stream._file.{attr} if it exists

Resolves: #1344

@uncojohnco uncojohnco changed the title fix spooled temporary file exceptions on file upload fix spooled temporary file exceptions on file upload - 2 Nov 30, 2018
@davidism

Copy link
Copy Markdown
Member

Since the issue was only with Python 3's io implementation, you can skip the asserts on Python 2. Or maybe just try reading with csv.DictReader like the example?

@davidism davidism added this to the 0.15 milestone Dec 1, 2018
@uncojohnco

Copy link
Copy Markdown
Author

Yay the tests are passing now 🎉
Can this be considered done now?

@davidism

davidism commented Dec 3, 2018

Copy link
Copy Markdown
Member

Rebased, added changelog, refactored tests.

New test runs on Python 2 and 3, tests small and large files with and without SpooledTemporaryFile available. Uses csv.reader to test file like example from issue.

@davidism davidism merged commit 0a0c47d into pallets:master Dec 3, 2018
abathur referenced this pull request in coleifer/sqlite-web Mar 23, 2019
Specifically, Flask (via werkzeug), uses a SpooledTemporaryFile to store
the upload data. This file is opened in mode "wb+", which isn't
compatible with the csv reader. TextIOWrapper can be used to translated
the data, but the fucking SpooledTemporaryFile doesn't implement the
fucking IOBase APIs. The issue is being bikeshedded by some assclown
whose avatar is literally an ass: python/cpython#3249
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SpooledTemporaryFile exceptions on file upload

2 participants