#13600 closed (fixed)
OverflowError not caught in django.views.static.serve
Reported by: | Konstantin Hlyzov | Owned by: | nobody |
---|---|---|---|
Component: | HTTP handling | Version: | 1.2 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I noticed that sometimes I get an "OverflowError: mktime argument out of range" error in django.views.static.serve, when a request is made with a strange date, say, request.META contents something like {'HTTP_IF_MODIFIED_SINCE': 'Mon, 28 May 3121 28:25:26 GMT'}.
Python docs say on this that the exceptions raised in mktime are either ValueError (if caught in Python layer) or OverflowError (if caught in C layer).
I suppose it could be fixed with replacing the third endmost line in django.views.static.was_modified_since from actual
except (AttributeError, ValueError):
to
except (AttributeError, ValueError, OverflowError):
Probably, there has been some reason not to catch OverflowErrors, then sorry.
Attachments (1)
Change History (12)
comment:1 by , 15 years ago
Description: | modified (diff) |
---|
comment:2 by , 15 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
follow-up: 5 comment:3 by , 14 years ago
Component: | Uncategorized → HTTP handling |
---|---|
Resolution: | worksforme |
Status: | closed → reopened |
Version: | 1.1 → 1.2 |
I can reproduce it, and I've just seen it on live. Here is the relevant part of the stack trace.
comment:5 by , 14 years ago
Replying to adamnelson:
I can reproduce it, and I've just seen it on live. Here is the relevant part of the stack trace.
Can you reproduce the error condition at will?. If so, could you paste the text version of the stack trace?. There is a button for that in the exception page generated by Django when running with DEBUG=True.
comment:6 by , 14 years ago
Here is the text version:
Traceback (most recent call last): File "/var/www/yipit-env/lib/python2.6/site-packages/django/core/handlers/base.py", line 100, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/var/www/yipit-env/lib/python2.6/site-packages/staticfiles/views.py", line 32, in serve show_indexes=show_indexes) File "/var/www/yipit-env/lib/python2.6/site-packages/django/views/static.py", line 61, in serve statobj[stat.ST_MTIME], statobj[stat.ST_SIZE]): File "/var/www/yipit-env/lib/python2.6/site-packages/django/views/static.py", line 129, in was_modified_since header_mtime = mktime_tz(parsedate_tz(matches.group(1))) File "/usr/lib/python2.6/email/_parseaddr.py", line 146, in mktime_tz t = time.mktime(data[:8] + (0,)) OverflowError: mktime argument out of range
comment:7 by , 14 years ago
Oops, thought you just wanted the stack trace in text. These are from a live site so these are from djangodberrorlog. I'll try to replicate myself.
comment:8 by , 14 years ago
I've updated the gist with the reproducible version. The easiest way to replicate this is to use http://modifyheaders.mozdev.org/ and modify:
If-Modified-Since to Mon, 29 Jul 3121 29:24:25 GMT
by , 14 years ago
Attachment: | 13600.diff added |
---|
comment:9 by , 14 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
comment:10 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
I can't reproduce the problem you describe -- using Python 2.6, the date "Mon 28 May 3121 28:25:26" actually parses correctly as "Tue, 29 May 3121 04:25:26"; using Python 2.5, it raises a ValueError. (Both of these tests were running under Mac OSX).
Closing worksforme; If you can provide more specific reproduction instructions, please reopen.