+ def test_year_out_of_range(self):
+ self.client.get('/dates/books/9999/')
+
def test_invalid_url(self):
with self.assertRaises(AttributeError):
self.client.get("/dates/books/2008/oct/01/nopk/")
}}}
Traceback:
{{{
File "/home/tim/code/django/django/views/generic/dates.py", line 58, in
_get_next_year
return date.replace(year=date.year + 1, month=1, day=1)
ValueError: year is out of range
}}}
I think returning a 404 response is the correct thing to do. Other mixins
besides `YearMixin` may be affected.
--
Ticket URL: <https://code.djangoproject.com/ticket/28209>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* has_patch: 0 => 1
Comment:
added a PR for this [https://github.com/django/django/pull/8508 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/28209#comment:1>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/28209#comment:2>
Comment (by aditbiswas1):
updated MonthMixin aswell which will throw the same error when crossing
year 9999
--
Ticket URL: <https://code.djangoproject.com/ticket/28209#comment:3>
* status: new => assigned
* owner: nobody => Adit Biswas
--
Ticket URL: <https://code.djangoproject.com/ticket/28209#comment:4>
Comment (by Adit Biswas):
Sorry, I'm not sure if I've done enough. Waiting for some discussion
around this before I continue making changes.
basically datetime will throw value errors whenever the year crosses 9999.
Wherever a datetime is manipulated to increment the date to cross 10000
will be affected.
{{{
YearMixin._get_next_year(self, date)
MonthMixin._get_next_month(self, date)
DayMixin._get_next_day(self, date)
WeekMixin._get_next_week(self, date)
}}}
While 404 would be an appropriate response for dates crossing the Year
9999
shouldnt the dates between 01-01-9999 and 31-12-9999 be handled
appropriately
if I throw 404 for each mixin the behaviour will be slightly odd. since
''/dates/books/9999/'' will throw a 404 but ''/dates/books/9999/01'' will
not
--
Ticket URL: <https://code.djangoproject.com/ticket/28209#comment:5>
* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/28209#comment:6>
Comment (by Tim Graham):
I think preventing a crash is of main importance at this point. Django
will probably be obsolete before handling dates with year 9999 is a
practical problem.
--
Ticket URL: <https://code.djangoproject.com/ticket/28209#comment:7>
Comment (by Adit Biswas):
added a PR for this [https://github.com/django/django/pull/8509 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/28209#comment:8>
* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/28209#comment:9>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"c2eea61dff44b16caab04928d582b856c2b8b615" c2eea61d]:
{{{
#!CommitTicketReference repository=""
revision="c2eea61dff44b16caab04928d582b856c2b8b615"
Fixed #28209 -- Made date-based generic views return a 404 rather than
crash when given an out of range date.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28209#comment:10>
Comment (by Tim Graham <timograham@…>):
In [changeset:"4e675999d530692f96745f5a54ba0376acd39e22" 4e67599]:
{{{
#!CommitTicketReference repository=""
revision="4e675999d530692f96745f5a54ba0376acd39e22"
[1.11.x] Fixed #28209 -- Made date-based generic views return a 404 rather
than crash when given an out of range date.
Backport of c2eea61dff44b16caab04928d582b856c2b8b615 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28209#comment:11>