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.

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

215215
216216 entity = self._next_entity_id
217217
218+ if entity not in self._entities:
219+ self._entities[entity] = {}
220+
218221 for component_instance in components:
219222
220223 component_type = type(component_instance)
224227
225228 self._components[component_type].add(entity)
226229
227- if entity not in self._entities:
228- self._entities[entity] = {}
229-
230230 self._entities[entity][component_type] = component_instance
231231 self.clear_cache()
232232
313313 self._components[component_type] = set()
314314
315315 self._components[component_type].add(entity)
316-
317- if entity not in self._entities:
318- self._entities[entity] = {}
319316
320317 self._entities[entity][component_type] = component_instance
321318 self.clear_cache()

The check that tells the two apart

failpass·tests/test_world.py::TestEntityExists::test_empty_entity
failpass·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.

Other bugs found in benmoran56/esper