From 2cace96be6d64b7dde7eb66d3ffc2c7f08ef644f Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Fri, 31 Jul 2026 16:43:51 -0400 Subject: [PATCH] Fixed #37242 -- Fixed reading null time fields in LayerMapping. Follow-up to 75d627888bf42f8de6064a0bd665c98c0df66c55. --- django/contrib/gis/gdal/field.py | 2 +- tests/gis_tests/data/has_nulls/has_nulls.geojson | 1 - tests/gis_tests/gdal_tests/test_ds.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/django/contrib/gis/gdal/field.py b/django/contrib/gis/gdal/field.py index 1a2218821a45..450e7d3720b7 100644 --- a/django/contrib/gis/gdal/field.py +++ b/django/contrib/gis/gdal/field.py @@ -217,7 +217,7 @@ def value(self): seconds = int(ss.value) milliseconds = int(round((ss.value - seconds) * 1000)) return time(hh.value, mn.value, seconds, milliseconds * 1000) - except (ValueError, GDALException): + except (TypeError, ValueError, GDALException): return None diff --git a/tests/gis_tests/data/has_nulls/has_nulls.geojson b/tests/gis_tests/data/has_nulls/has_nulls.geojson index 8ae52a187782..3bd34308fe13 100644 --- a/tests/gis_tests/data/has_nulls/has_nulls.geojson +++ b/tests/gis_tests/data/has_nulls/has_nulls.geojson @@ -59,7 +59,6 @@ "type": "Feature", "properties": { "uuid": "fa2ba67c-a135-4338-b924-a9622b5d869f", - "time": "00:00:00", "integer": null, "num": null }, diff --git a/tests/gis_tests/gdal_tests/test_ds.py b/tests/gis_tests/gdal_tests/test_ds.py index ea16c06f4a25..a5904cbbc772 100644 --- a/tests/gis_tests/gdal_tests/test_ds.py +++ b/tests/gis_tests/gdal_tests/test_ds.py @@ -110,7 +110,7 @@ None, datetime.strptime("2018-11-29T03:02:52", datetime_format), ], - "time": [time(11, 32, 14, 123000), time(0), time(3, 2, 52)], + "time": [time(11, 32, 14, 123000), None, time(3, 2, 52)], }, fids=range(3), ),