#27287: IndexError in logging on runserver broken pipe error
------------------------------------+--------------------------------------
Reporter: Sjoerd Job Postmus | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by Tim Graham):
* needs_better_patch: => 0
* component: Uncategorized => Utilities
* needs_tests: => 0
* needs_docs: => 0
Old description:
> In `WSGIServer.handle_error`, on a broken pipe, it calls `logger.info`
> with 2 arguments: a format and an address.
>
> This uses the `ServerFormatter`, which expects either 0 or >= 2 args.
>
> {{{
> Traceback (most recent call last):
> File "/usr/lib/python2.7/logging/__init__.py", line 851, in emit
> msg = self.format(record)
> File "/usr/lib/python2.7/logging/__init__.py", line 724, in format
> return fmt.format(record)
> File "/.../django/utils/log.py", line 173, in format
> if args[1][0] == '2':
> IndexError: tuple index out of range
> Logged from file basehttp.py, line 85
> }}}
>
> I think a good fix might be to make it check against `len(args) < 2`
> instead of `len(args) == 0`.
>
> While the code is being touched, it might also be a good idea to write
> `status_code = args[1]`, and use that in the `if`-chain.
New description:
In `WSGIServer.handle_error`, on a broken pipe, it calls `logger.info`
with 2 arguments: a format and an address.
This uses the `ServerFormatter`, which expects either 0 or >= 2 args.
{{{
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 851, in emit
msg = self.format(record)
File "/usr/lib/python2.7/logging/__init__.py", line 724, in format
return fmt.format(record)
File "/.../django/utils/log.py", line 173, in format
if args[1][0] == '2':
IndexError: tuple index out of range
Logged from file basehttp.py, line 85
}}}
I think a good fix might be to make it check against `len(args) < 2`
instead of `len(args) == 0`.
While the code is being touched, it might also be a good idea to write
`status_code = args[1]`, and use that in the `if`-chain.
==
--
Comment:
Duplicate of #27271.
--
Ticket URL: <https://code.djangoproject.com/ticket/27287#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.b164c312fe054a5b96a844e15bf82ff3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.