#28209: Date-based generic views can fail with ValueError: year is out of range
-----------------------------------------+------------------------
               Reporter:  Tim Graham     |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  Generic views  |        Version:  1.11
               Severity:  Normal         |       Keywords:
           Triage Stage:  Accepted       |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 Test to reproduce:
 {{{ #!diff
 diff --git a/tests/generic_views/test_dates.py
 b/tests/generic_views/test_dates.
 index bf462b4..76d4b2b 100644
 --- a/tests/generic_views/test_dates.py
 +++ b/tests/generic_views/test_dates.py
 @@ -661,6 +661,9 @@ class DateDetailViewTests(TestDataMixin, TestCase):
          self.assertEqual(res.context['book'], b)
          self.assertTemplateUsed(res, 'generic_views/book_detail.html')

 +    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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.efe3f8bda2c20b852d641c001912ec44%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to