Invalidate depsgraph.object_instances when freed, this resolves a crash when accessing the object instances after iteration has finished.
Unlike most other collections, object_instances is only valid while the iterator is in-memory.
The Python/RNA API needs to inline int/string collection lookups so the Python instance can be created before the iterator ends.
Notes:
- I'd prefer this over D15754 as this also resolves the crash accessing any references held to the object_instances after iteration has finished, where D15754 only disables direct string/int lookups.
- This change is more intrusive than I'd like, arguably using py_instance here is awkward as allowing integer lookups, only to return freed RNA data isn't so great, nevertheless it avoids the crash in a way the RNA API supports (via RNA_POINTER_INVALIDATE).