#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>