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

Fixed traceback formatting for syntax errors #1235

Merged
merged 1 commit into from Mar 24, 2016

Conversation

Projects
None yet
3 participants
@MarSoft
Contributor

MarSoft commented Mar 24, 2016

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
    worker.init_process()
  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
    super().init_process()
  File "/usr/lib/python3.5/site-packages/gunicorn/workers/base.py", line 122, in init_process
    self.load_wsgi()
  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__
    capture_locals=capture_locals)
  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.

@MarSoft MarSoft changed the title from Fixed traceback formatting to Fixed traceback formatting for syntax errors Mar 24, 2016

@MarSoft

This comment has been minimized.

Show comment
Hide comment
@MarSoft

MarSoft Mar 24, 2016

Contributor

I have no idea how to properly test this or where to place such tests..

Contributor

MarSoft commented Mar 24, 2016

I have no idea how to properly test this or where to place such tests..

@berkerpeksag

This comment has been minimized.

Show comment
Hide comment
@berkerpeksag

berkerpeksag Mar 24, 2016

Collaborator

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.

Collaborator

berkerpeksag commented Mar 24, 2016

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.

@tilgovi

This comment has been minimized.

Show comment
Hide comment
@tilgovi

tilgovi Mar 24, 2016

Collaborator

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.

Collaborator

tilgovi commented Mar 24, 2016

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.

@tilgovi

This comment has been minimized.

Show comment
Hide comment
@tilgovi

tilgovi Mar 24, 2016

Collaborator

Or rather, the bug was there before #1228 reformatted it :).

Collaborator

tilgovi commented Mar 24, 2016

Or rather, the bug was there before #1228 reformatted it :).

@tilgovi tilgovi added the bug :( label Mar 24, 2016

@berkerpeksag

This comment has been minimized.

Show comment
Hide comment
@berkerpeksag

berkerpeksag Mar 24, 2016

Collaborator

You're right, I keep forgetting traceback API :) Looks good to me.

Thanks!

Collaborator

berkerpeksag commented Mar 24, 2016

You're right, I keep forgetting traceback API :) Looks good to me.

Thanks!

@tilgovi

This comment has been minimized.

Show comment
Hide comment
@tilgovi

tilgovi Mar 24, 2016

Collaborator

Thanks, @MarSoft!

Collaborator

tilgovi commented Mar 24, 2016

Thanks, @MarSoft!

@tilgovi tilgovi merged commit 3b0529d into benoitc:master Mar 24, 2016

1 check passed

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

fofanov pushed a commit to fofanov/gunicorn that referenced this pull request Mar 16, 2018

Merge pull request benoitc#1235 from MarSoft/fix-traceback
Fixed traceback formatting for syntax errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment