#3306: [patch] tzinfo raises OverflowError for years out of time.mktime 
supported
range
---------------------------------------------+------------------------------
Reporter:  ymasuda <[EMAIL PROTECTED]>  |       Owner:  adrian
Type: defect | Status: new Priority: normal | Milestone: Component: Admin interface | Version: Severity: normal | Keywords: ---------------------------------------------+------------------------------
'''Summary'''

In django.utils.tzinfo, LocalTimezone._isdst() is calling time.time() to
indicate DST status of the timezone.
This causes OverflowError if you put a DateTimeField and list it in
Admin.list_display, then save instance with
far future date (namely beyond 2038) and display it in admin site's
changelist.

'''Symptom with example'''

Assume 'sandbox.foo' application has following model:
{{{
class Bar(models.Model):
    date = models.DateTimeField()
    class Admin:
        list_display = ('date',)
}}}

And an user create Bar instance of 3000/01/01:
{{{
>>> from sandbox.foo.models import Bar
>>> from datetime import datetime
>>> b = Bar(date=datetime(3000, 1, 1))
>>> b.save()
>>>
}}}

The instance is saved silently (even in admin's Create New Bar view), but
your changelist view
(http://yourdomain/admin/foo/bar/) will raise OverflowError:
{{{
OverflowError at /admin/foo/bar/
mktime argument out of range

Request Method: GET
Request URL:    http://localhost:8000/admin/foo/bar/
Exception Type: OverflowError
Exception Value:        mktime argument out of range
Exception Location:
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/django/utils/tzinfo.py in _isdst, line 51
}}}

'''Proposed resolution'''

The attached patch includes modification in LocalTimezone._isdst() so that
the years out of
mktime-supported range (1970-2037) will be clipped as 1970 or 2037.
Applying this patch will allow user to specify years in range (1900-9999).

'''Note'''

As an alternative resolution, Date(Time)Field may validate its value to
reject years out of (1970-2037).

--
Ticket URL: <http://code.djangoproject.com/ticket/3306>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django 
updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to