Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#27271 closed Bug (fixed)

ServerFormatter should handle simple string messages with or without args

Reported by: Sergey Fursov Owned by: Sergey Fursov
Component: Utilities Version: 1.10
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

In our selenium tests we see next error:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/logging/__init__.py", line 853, in emit
    msg = self.format(record)
  File "/usr/local/lib/python2.7/logging/__init__.py", line 726, in format
    return fmt.format(record)
  File "/usr/local/lib/python2.7/site-packages/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

basehttp.py module on line 85 logs info message about Broken pipe error as

logger.info("- Broken pipe from %s\n", client_address)

but ServerFormatter can't handle simple log messages with formatting args. Also, with default logging configuration ServerFormatter can't process records without server_time variable. Both cases can be easily reproduced by next code:

import logging
logger = logging.getLogger('django.server')
logger.info('some message with arg: %s', 'arg value')
logger.info('some message')

Bug was introduced in #25684.

Change History (4)

comment:1 by Sergey Fursov, 8 years ago

Has patch: set
Owner: changed from nobody to Sergey Fursov
Status: newassigned

comment:2 by Tim Graham, 8 years ago

Description: modified (diff)
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:3 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 6709ea4:

Fixed #27271 -- Fixed a crash in runserver logging.

Allowed ServerFormatter to handle simple string messages or messages with
formatting arguments. The formatter will set the server_time variable on
the log record if it's required by the format string but wasn't passed in
extra parameters.

comment:4 by Tim Graham <timograham@…>, 8 years ago

In bcdd13d:

[1.10.x] Fixed #27271 -- Fixed a crash in runserver logging.

Allowed ServerFormatter to handle simple string messages or messages with
formatting arguments. The formatter will set the server_time variable on
the log record if it's required by the format string but wasn't passed in
extra parameters.

Backport of 6709ea4ae91b906742506ac0c42a3a272991001f from master

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