-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Correctly handle unavailable .fileno() support for io.BytesIO instances #1174
Comments
If the filelike response object has no `fileno` attribute, then skip trying to use sendfile rather than failing with an error. Close #1160
fileno()
support for io.BytesIO
instances
fileno()
support for io.BytesIO
instances
I guess this is a critical bug since it breaks a lot of cases like |
is_fileobject usgae was removed due to the use of the `tell` method check. This change remove this check wich allows us to completely test if fileno() is usable. Also it handle most of the exceptions around created by breaking changes across Python versions. Hopefully we are good now. fix #1174
fwiw, I guess we were both looking at this at the same time, and I just posted #1176 with an alternative... |
@wbolster Thanks for the patch! The solutions are similar but I quite like the idea of having a function apart for it, so it may be later unit-tested eventually. File objects were better defined in old versions (and Gunicorn starts to get old) [1] . I see now that it has been reduced. Although this tests is done there to test if the file-like object return a usable file descriptior so we can use [1] https://docs.python.org/2.5.2/lib/bltin-file-objects.html |
|
Hi, I'm not sure if this is exactly related, but I'm having a similar issue with the following Traceback: Traceback (most recent call last): Here is a git copy if it helps: https://github.com/DCuddies/simplecontract I'm using BytesIO in order to store a docx object, and then let the users download that docx object. I'm at a loss at this point as to how to fix the issue, any help would be appreciated. |
@DCuddies sorry have been side tracked. Patch is now is master. If everything goes fine, i will make a release over the week-end. |
@benoitc That's great, thanks. |
Sorry I have been offline. Thanks for the support @benoitc. I will be more proactive about getting good feedback and testing, even for these one line fixes, going forward. |
@tilgovi np :) thanks for all the work you already do anyway :) |
awesome. any chance of cutting a new release? currently |
19.4.4 has just been released. enjoy! cc @wbolster @DCuddies |
So i'm at 19.4.4 and:
this doesn't seem right either, does it? |
see #1178 |
The update fixed it, thanks! |
is_fileobject usgae was removed due to the use of the `tell` method check. This change remove this check wich allows us to completely test if fileno() is usable. Also it handle most of the exceptions around created by breaking changes across Python versions. Hopefully we are good now. fix benoitc#1174
The changes introduced in 98c9e3b#diff-6607b435d6ee868f251dbdd1a6d0edecL357 are wrong and lead to crashes for
io.BytesIO
instances which do have a.fileno()
method but raise another exception instead:This exception was already caught properly in the earlier code, a few lines below.
The text was updated successfully, but these errors were encountered: