Opened 8 years ago

Last modified 8 years ago

#27287 closed Bug

IndexError on broken pipe — at Initial Version

Reported by: Sjoerd Job Postmus Owned by: nobody
Component: Utilities Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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.

Change History (0)

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