Skip to content

Commit 91038f2

Browse files
committed
Python bindings: robustify commit fdc4a41 (master only)
1 parent aa69d31 commit 91038f2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

swig/include/python/gdal_python.i

+2-1
Original file line numberDiff line numberDiff line change
@@ -5558,7 +5558,8 @@ class VSIFile(BytesIO):
55585558
return self.SetAsBoolean(value)
55595559
if type == GAAT_STRING:
55605560
if isinstance(value, int):
5561-
if "GDALDataType" in self.GetMetadataItem("type") and value >= GDT_Byte and value < GDT_TypeCount:
5561+
metadata_item = self.GetMetadataItem("type")
5562+
if metadata_item and ("GDALDataType" in metadata_item) and value >= GDT_Byte and value < GDT_TypeCount:
55625563
return self.SetAsString(GetDataTypeName(value))
55635564
else:
55645565
return self.SetAsString(str(value))

0 commit comments

Comments
 (0)