Toblerity / Fiona

Fiona reads and writes geographic data files
https://fiona.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.15k stars 201 forks source link

KeyError after assigning new key-value pair to the `"properties"` field of a `Feature` #1430

Closed grabermtw closed 1 week ago

grabermtw commented 1 month ago

Expected behavior and actual behavior.

Assigning new key-value pairs to the "properties" field of a fiona.Feature stopped working in Fiona 1.10b2.

Steps to reproduce the problem.

myFeature = fiona.Feature(geometry=fiona.Geometry(coordinates=(1,1), type='Point'), id='0', properties=fiona.Properties())
myFeature["properties"]["foo"] = "bar"
print(myFeature["properties"]["foo"])

# In Fiona 1.10b1 and earlier
> bar

# In Fiona 1.10b2 (and 1.10b3)
> KeyError: 'foo'

Operating system

AlmaLinux 9.3

Fiona and GDAL version and provenance

Fiona 1.10b2

GDAL 3.6.4 built from source

sgillies commented 1 month ago

@grabermtw Thanks for the report! I can reproduce this. Meanwhile, Feature isn't a dict anymore and will be immutable in a future version. myFeature.properties["foo"] = "bar" will work, but it would be best to avoid this usage if you can.

grabermtw commented 3 weeks ago

Thanks for the info! Will avoid that usage going forward.