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
No response and No exception traceback when render_template failed and DEBUG=True #1995
Comments
you are using werkzueg's if you want to use |
I expect it print exception traceback in console and show 500 internal server error in browser. |
@guyskk which version Flask does you using? |
@luke0922 flask 0.11.1 and python3.5 |
@guyskk it seems work as you said, i just try in python 3.5.1 and get the same result, maybe it's a bug. |
Can reproduce. No problems with Python 2. |
I reproduced this with flask 0.11.1 and python 3.5.2 |
I found the try:
execute(self.server.app)
except (socket.error, socket.timeout) as e: # go here
self.connection_dropped(e, environ)
except Exception:
if self.server.passthrough_errors:
raise and in python3.5 issubclass(jinja2.exceptions.TemplateNotFound, socket.error)
True |
here is the thing: In [23]: jinja2.exceptions.TemplateNotFound.__bases__
Out[23]: (OSError, LookupError, jinja2.exceptions.TemplateError)
In [24]: socket.error is OSError
Out[24]: True |
I see, I think under Python 3 we should use one of the other error types that the socket module has to offer: https://docs.python.org/3/library/socket.html#exceptions -- not sure if |
Also thank you so much @qingyunha for finding this! |
Cool stuff. I think we could keep a tuple of error types for socket stuff in the compat module and catch on that. Not my favorite change. |
Apparently this change was done in Python 3.3 too. |
BTW, the reason this exception even bubbles up this far is pallets/werkzeug#954 |
We could try to detect the actual error codes relevant for socket loss. |
is this reasonable that Template-Not-Found is an OS error? |
I don't really know but changing it won't solve the problem (because there might be other errors that get accidentally caught) On 28 August 2016 11:58:09 CEST, qingyunha notifications@github.com wrote:
Sent from my Android device with K-9 Mail. Please excuse my brevity. |
We could also detect if the exception is of the exact type |
We can probably determine error is not subclass of issubclass(socket.error, IOError) # True
issubclass(socket.error, OSError) # True |
Yes, but also: issubclass(OSError, IOError) # True
issubclass(IOError, OSError) # True So I don't think this will help us much. |
>>> # Python 3
>>> socket.error is OSError
True
>>> socket.error()
OSError() In Python 3, >>> # Python 2
>>> issubclass(socket.error, OSError)
False |
This is an issue with Werkzeug's dev server, not with Flask. Other servers such as Gunicorn do not have the issue. Reported at pallets/werkzeug#1127. |
Here is the code:
app.py
Run it by
or
then visit
http://127.0.0.1:5000
will seeERR_EMPTY_RESPONSE
in browser and nothing in console.The text was updated successfully, but these errors were encountered: