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

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

Merged
merged 2 commits into from
Dec 3, 2018
Merged

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

merged 2 commits into from
Dec 3, 2018

Conversation

uncojohnco
Copy link

@uncojohnco uncojohnco commented Nov 30, 2018

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
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
Author

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

@davidism
Copy link
Member

davidism commented Dec 3, 2018

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