Without this patch, on current Gunicorn version I get the following traceback if I have a syntax error in my program:
File "/home/mars/myproject/views/item.py", line 494
return render(request, 'add_item.html',
SyntaxError: invalid syntax
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
File "/usr/lib/python3.5/site-packages/aiohttp-0.21.2-py3.5-linux-x86_64.egg/aiohttp/worker.py", line 30, in init_process
File "/usr/lib/python3.5/site-packages/gunicorn/workers/base.py", line 122, in init_process
File "/usr/lib/python3.5/site-packages/gunicorn/workers/base.py", line 140, in load_wsgi
tb_string = traceback.format_exc(exc_tb)
File "/usr/lib/python3.5/traceback.py", line 163, in format_exc
return "".join(format_exception(*sys.exc_info(), limit=limit, chain=chain))
File "/usr/lib/python3.5/traceback.py", line 117, in format_exception
type(value), value, tb, limit=limit).format(chain=chain))
File "/usr/lib/python3.5/traceback.py", line 474, in __init__
File "/usr/lib/python3.5/traceback.py", line 332, in extract
if limit >= 0:
TypeError: unorderable types: traceback() >= int()
This patch removes additional "During handling of the above exception..." traceback.
Fixed traceback formatting
I have no idea how to properly test this or where to place such tests..
Did you get the same traceback in Python 3.4? This might be a regression in Python 3.5's traceback module. I have already fixed two of them in Python 3.5.
Actually, I think this is just an error that needs to be corrected, @berkerpeksag. The format_exc function takes a limit argument, not a traceback. I missed this when reviewing #1228.
Or rather, the bug was there before #1228 reformatted it :).
You're right, I keep forgetting traceback API :) Looks good to me.