[Django] #27233: IndexError when using django.request

10 views
Skip to first unread message

Django

unread,
Sep 16, 2016, 1:47:04 AM9/16/16
to django-...@googlegroups.com
#27233: IndexError when using django.request
-------------------------+-------------------------------------------------
Reporter: ben- | Owner: nobody
whale |
Type: Bug | Status: new
Component: | Version: 1.10
Uncategorized |
Severity: Normal | Keywords: django.request runserver IndexError
Triage Stage: | Has patch: 0
Unreviewed |
Easy pickings: 0 | UI/UX: 0
-------------------------+-------------------------------------------------
To replicate the following stacktrace:

{{{
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit
msg = self.format(record)
File "/usr/lib/python2.7/logging/__init__.py", line 734, in format
return fmt.format(record)
File "<path_to_project>/mwe/venv/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
}}}

follow these steps:
1) create a project "django-admin startproject <project_name>"
2) put the following into settings.py
{{{
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'custom': {
'()': 'django.utils.log.ServerFormatter',
'format': '[%(server_time)s] %(message)s %(request)r',
}
},
'handlers': {
'custom': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'custom',
},
},
'loggers': {
'django.request': {
'handlers': ['custom'],
'level': 'DEBUG',
'propagate': False,
},
}
}
}}}
3) run the server "python manage.py runserver"
4) navigate to <server>/foobar

The traceback should be printed in the console.

TBH I was sure what to expect as the documentation
(https://docs.djangoproject.com/en/1.10/topics/logging/#django-request)
doesn't make it clear if the django.request logger is used when using the
runserver command, especially when django.server essentially replicates
django.request when running using runserver.

The error occurs (I think) as the format method expects args to be a tuple
consisting of the url, the response status code, and a number (the amount
of data transferred?) but instead receives a tuple containing only the
url.

--
Ticket URL: <https://code.djangoproject.com/ticket/27233>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 16, 2016, 4:17:47 PM9/16/16
to django-...@googlegroups.com
#27233: IndexError when using django.request
-------------------------------------+-------------------------------------
Reporter: ben-whale | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution:
Keywords: django.request | Triage Stage:
runserver IndexError | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Unless you say where the bug is, it looks invalid to me to use
'django.utils.log.ServerFormatter' attached to a logger other than
'django.server`'.

--
Ticket URL: <https://code.djangoproject.com/ticket/27233#comment:1>

Django

unread,
Sep 18, 2016, 8:33:44 PM9/18/16
to django-...@googlegroups.com
#27233: IndexError when using django.request
-------------------------------------+-------------------------------------
Reporter: ben-whale | Owner: nobody
Type: Bug | Status: new

Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution:
Keywords: django.request | Triage Stage:
runserver IndexError | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by ben-whale):

Replying to [comment:1 timgraham]:


> Unless you say where the bug is, it looks invalid to me to use
'django.utils.log.ServerFormatter' attached to a logger other than
'django.server`'.

Haha ha ha. Yes. Yes it is. Some debugging latter and I can see that you
are quite right.

--
Ticket URL: <https://code.djangoproject.com/ticket/27233#comment:2>

Django

unread,
Sep 18, 2016, 8:34:41 PM9/18/16
to django-...@googlegroups.com
#27233: IndexError when using django.request
-------------------------------------+-------------------------------------
Reporter: ben-whale | Owner: nobody
Type: Bug | Status: closed
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution: invalid

Keywords: django.request | Triage Stage:
runserver IndexError | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by ben-whale):

* status: new => closed
* resolution: => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/27233#comment:3>

Reply all
Reply to author
Forward
0 new messages