Opened 13 years ago

Closed 13 years ago

#15672 closed Bug (fixed)

wsgi handler bug in 1.3

Reported by: vkryachko Owned by: vkryachko
Component: Core (Other) Version: 1.3
Severity: Release blocker Keywords:
Cc: kinpoo Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When environ cannot be parsed, the following exception i raised:

File "/var/www/dynamic/virtualenv/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 264, in call

logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path,

UnboundLocalError: local variable 'request' referenced before assignment

Attachments (2)

ticket-15672.diff (2.1 KB ) - added by vung 13 years ago.
Removes references to request in the wsgi and mod_python handlers and adds a test
ticket-15672-force_unicode-with-ignore.diff (3.2 KB ) - added by kinpoo 13 years ago.
ignore UnicodeDecodeError, does not handle it as bad request, let handle it as 404

Download all attachments as: .zip

Change History (13)

comment:1 by Russell Keith-Magee, 13 years ago

Triage Stage: UnreviewedAccepted
Version: 1.3-rc11.3

comment:2 by Adrian Holovaty, 13 years ago

Resolution: fixed
Status: newclosed

In [15918]:

Fixed #15672 -- Fixed bug in core/handlers/wsgi.py where we were referring to the 'request' variable before assigning to it. Thanks for the report, vkryachko

comment:3 by vkryachko, 13 years ago

Resolution: fixed
Severity: Normal
Status: closedreopened
Type: Bug

Thanks for the fix, adrian. But looking at the 1.3.x branch, I see that this fix has not been backported there, so I think the issue has to be reopened. I would have backported it myself, but I don't have write access to the SVN. Regards

comment:4 by Russell Keith-Magee, 13 years ago

Resolution: fixed
Status: reopenedclosed

In [16009]:

[1.3.X] Fixed #15672 -- Fixed bug in core/handlers/wsgi.py where we were referring to the 'request' variable before assigning to it. Thanks for the report, vkryachko

Backport of r15918 from trunk.

by vung, 13 years ago

Attachment: ticket-15672.diff added

Removes references to request in the wsgi and mod_python handlers and adds a test

comment:5 by vung, 13 years ago

Has patch: set
Resolution: fixed
Status: closedreopened

'request' was referenced twice so the bug is still present (see test)

Same thing happens in the mod_python handler.

comment:6 by Russell Keith-Magee, 13 years ago

Easy pickings: unset
Severity: NormalRelease blocker

comment:7 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: reopenedclosed

In [16082]:

(The changeset message doesn't reference this ticket)

comment:8 by Jannis Leidel, 13 years ago

In [16083]:

[1.3.X] Fixed #15672 -- Refined changes made in r15918. Thanks, vung.

Backport from trunk (r16082).

comment:9 by kinpoo, 13 years ago

Cc: kinpoo added
UI/UX: unset
  1. I think it might be handle as a bad URL and output 404 not found, but not 400 bad request.
  1. Sometimes, add some unnecessary information in URL for SEO reason, example: "/123-外贸", encoded as "/123-%E5%A4%96%E8%B4%B8", if it broken, looks like "/123-%E5", I can also get the correct resource and redirect to correct url.

by kinpoo, 13 years ago

ignore UnicodeDecodeError, does not handle it as bad request, let handle it as 404

comment:10 by kinpoo, 13 years ago

Resolution: fixed
Status: closedreopened
Triage Stage: AcceptedDesign decision needed

comment:11 by Karen Tracey, 13 years ago

Resolution: fixed
Status: reopenedclosed

This ticket was about a straightforward bug: use of a variable before it had been set. The recent comments and re-opening of this ticket don't seem related to that simple bug, which has been fixed. If you think this area of the code has some other problem please open a new ticket to track that. Reclosing this ticket as fixed, because the UnboundLocalError has been fixed.

Note: See TracTickets for help on using tickets.
Back to Top