Whole file
benmoran56/esper
The author described this change as “FIX: create_entity() do not create entity without components injected (#81)”. It counts as a record because the checks below fail on the code as it stood at c413eccd6 and pass on b9aee53ba, with nothing else changed between the two runs.
Projectbenmoran56/esper
Fix saved2023-04-28
Sharing licenceMIT · LICENSE
Change size+3 −6
What the code was meant to do, written into the code itself as a save note
FIX: create_entity() do not create entity without components injected (#81)
The change
| 215 | 215 | ||
| 216 | 216 | entity = self._next_entity_id | |
| 217 | 217 | ||
| 218 | + | if entity not in self._entities: | |
| 219 | + | self._entities[entity] = {} | |
| 220 | + | ||
| 218 | 221 | for component_instance in components: | |
| 219 | 222 | ||
| 220 | 223 | component_type = type(component_instance) | |
| ⋯ | |||
| 224 | 227 | ||
| 225 | 228 | self._components[component_type].add(entity) | |
| 226 | 229 | ||
| 227 | - | if entity not in self._entities: | |
| 228 | - | self._entities[entity] = {} | |
| 229 | - | ||
| 230 | 230 | self._entities[entity][component_type] = component_instance | |
| 231 | 231 | self.clear_cache() | |
| 232 | 232 | ||
| ⋯ | |||
| 313 | 313 | self._components[component_type] = set() | |
| 314 | 314 | ||
| 315 | 315 | self._components[component_type].add(entity) | |
| 316 | - | ||
| 317 | - | if entity not in self._entities: | |
| 318 | - | self._entities[entity] = {} | |
| 319 | 316 | ||
| 320 | 317 | self._entities[entity][component_type] = component_instance | |
| 321 | 318 | self.clear_cache() | |
The check that tells the two apart
fail→pass·tests/test_world.py::TestEntityExists::test_empty_entity
fail→pass·tests/test_world.py::test_adding_component_to_not_existing_entity_raises_error
Check file tests/test_world.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itc413eccd6eae12556d0fbad48298f259b6c7ea7b
Broken version dated2023-04-06
Moduleesper.__init__
Units changedWorld
Fingerprint4d71fe61429b2341
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.