#35683: django.utils.timezone.make_naive can underflow for timezones close to
datetime.min
-------------------------------------+-------------------------------------
     Reporter:  Liam DeVoe           |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  5.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

 * component:  Uncategorized => Database layer (models, ORM)
 * stage:  Unreviewed => Accepted

Comment:

 Replicated, thank you!

 Should be an issue in MySQL and Oracle as well - refs #23820
 Rough testcase:
 {{{#!diff
 --- a/tests/backends/sqlite/test_operations.py
 +++ b/tests/backends/sqlite/test_operations.py
 @@ -1,8 +1,10 @@
  import unittest
 +from datetime import datetime

  from django.core.management.color import no_style
  from django.db import connection
 -from django.test import TestCase
 +from django.test import TestCase, override_settings
 +from django.utils import timezone

  from ..models import Person, Tag

 @@ -86,3 +88,10 @@ class SQLiteOperationsTests(TestCase):
              "zzz'",
              statements[-1],
          )
 +
 +    @override_settings(USE_TZ=True, TIME_ZONE="UTC")
 +    def test_adapt_datetimefield_value_close_to_datetime_min(self):
 +        africa_nairobi_tz = timezone.get_fixed_timezone(180)
 +        value = datetime.min.replace(tzinfo=africa_nairobi_tz)
 +
 +        connection.ops.adapt_datetimefield_value(value)  # OverflowError
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35683#comment:2>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107019169563e7a-a68f784f-e4ac-4efc-aab6-435847ffca7a-000000%40eu-central-1.amazonses.com.

Reply via email to