Fixed #28495 -- Converted GDAL Feature.fields to strings

This commit is contained in:
Claude Paroz 2017-08-14 11:32:37 +02:00
parent 41640760df
commit 546412e673
2 changed files with 8 additions and 2 deletions

View File

@ -82,8 +82,13 @@ class Feature(GDALBase):
@property @property
def fields(self): def fields(self):
"Return a list of fields in the Feature." "Return a list of fields in the Feature."
return [capi.get_field_name(capi.get_field_defn(self._layer._ldefn, i)) return [
for i in range(self.num_fields)] 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 @property
def geom(self): def geom(self):

View File

@ -195,6 +195,7 @@ class DataSourceTest(unittest.TestCase):
# Making sure we get the proper OGR Field instance, using # Making sure we get the proper OGR Field instance, using
# a string value index for the feature. # a string value index for the feature.
self.assertIsInstance(feat[k], v) self.assertIsInstance(feat[k], v)
self.assertIsInstance(feat.fields[0], str)
# Testing Feature.__iter__ # Testing Feature.__iter__
for fld in feat: for fld in feat: