From 546412e6731e5e31b8450c35e3dae8ec26bc008c Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Mon, 14 Aug 2017 11:32:37 +0200 Subject: [PATCH] Fixed #28495 -- Converted GDAL Feature.fields to strings --- django/contrib/gis/gdal/feature.py | 9 +++++++-- tests/gis_tests/gdal_tests/test_ds.py | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/django/contrib/gis/gdal/feature.py b/django/contrib/gis/gdal/feature.py index cf42781ec4f..6e857ca0740 100644 --- a/django/contrib/gis/gdal/feature.py +++ b/django/contrib/gis/gdal/feature.py @@ -82,8 +82,13 @@ class Feature(GDALBase): @property def fields(self): "Return a list of fields in the Feature." - return [capi.get_field_name(capi.get_field_defn(self._layer._ldefn, i)) - for i in range(self.num_fields)] + return [ + force_text( + capi.get_field_name(capi.get_field_defn(self._layer._ldefn, i)), + self.encoding, + strings_only=True + ) for i in range(self.num_fields) + ] @property def geom(self): diff --git a/tests/gis_tests/gdal_tests/test_ds.py b/tests/gis_tests/gdal_tests/test_ds.py index 0cf0abdc707..535aba70fb4 100644 --- a/tests/gis_tests/gdal_tests/test_ds.py +++ b/tests/gis_tests/gdal_tests/test_ds.py @@ -195,6 +195,7 @@ class DataSourceTest(unittest.TestCase): # Making sure we get the proper OGR Field instance, using # a string value index for the feature. self.assertIsInstance(feat[k], v) + self.assertIsInstance(feat.fields[0], str) # Testing Feature.__iter__ for fld in feat: