You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
wsgi.errors should be a text stream, not a binary stream #529
An output stream (file-like object) to which error output can be written, [...]. This should be a “text mode” stream; i.e., applications should use "\n" as a line ending [...]
(On platforms where the str type is unicode, the error stream should accept and log arbitrary unicode without raising an error; it is allowed, however, to substitute characters that cannot be rendered in the stream’s encoding.)
Why wasn't this raised sooner ?
Flask has been using wsgi.errors for >8 years. This repo has been using BytesIO since WsgiToAsgi exists (8 years).
Fascinating, I don't know how this went unnoticed all this time - I presume nobody ever tested it with Flask (that plus the WSGI-to-ASGI adapter code is not used very often I think).
Definitely needs to be fixed - this might just be a case where we can land a direct PR to change it.
Activity
andrewgodwin commentedon Sep 15, 2025
Fascinating, I don't know how this went unnoticed all this time - I presume nobody ever tested it with Flask (that plus the WSGI-to-ASGI adapter code is not used very often I think).
Definitely needs to be fixed - this might just be a case where we can land a direct PR to change it.
andrewgodwin commentedon Sep 15, 2025
Added a direct fix for this in #530, but that still does what the old code did - absorbs the errors and doesn't do anything with them.
Maybe we should point it at
sys.stderrinstead so it at least goes somewhere?andrewgodwin commentedon Sep 15, 2025
Ah, I now see this is what you did in your workaround. I think I'll just switch the PR to that.
Fixed django#529: wsgi.errors should be a StringIO (django#530)
carltongibson commentedon Sep 17, 2025
Thanks both. I think this is worth a point release — @andrewgodwin I'll get to that shortly if you don't first.
andrewgodwin commentedon Sep 18, 2025
Sounds good - I am travelling the next three weeks so I suspect you'll get there first!
carltongibson commentedon Sep 23, 2025
https://pypi.org/project/asgiref/3.9.2/