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

Conversation

Projects
None yet
2 participants
@uncojohnco
Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

commented Nov 30, 2018

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 uncojohnco force-pushed the uncojohnco:1344-SpooledTemporaryFile-exceptions-on-file-upload-v2 branch from ea6a68f to d8c3607 Dec 3, 2018

@uncojohnco

This comment has been minimized.

Copy link
Contributor Author

commented Dec 3, 2018

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

@davidism davidism force-pushed the uncojohnco:1344-SpooledTemporaryFile-exceptions-on-file-upload-v2 branch from e6196e2 to dd91f20 Dec 3, 2018

@davidism

This comment has been minimized.

Copy link
Member

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 force-pushed the uncojohnco:1344-SpooledTemporaryFile-exceptions-on-file-upload-v2 branch from dd91f20 to 3638d0e Dec 3, 2018

@davidism davidism merged commit 0a0c47d into pallets:master Dec 3, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

abathur referenced this pull request in coleifer/sqlite-web Mar 23, 2019

Fix issue streaming file upload into CSV parser.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.