Skip to content

Keey try_remove_component() from throwing a KeyError if the component isn't there#119

Merged
benmoran56 merged 1 commit into
benmoran56:masterfrom
mfeif:master
May 14, 2026
Merged

Keey try_remove_component() from throwing a KeyError if the component isn't there#119
benmoran56 merged 1 commit into
benmoran56:masterfrom
mfeif:master

Conversation

@mfeif
Copy link
Copy Markdown
Contributor

@mfeif mfeif commented May 13, 2026

try_remove_component was actually throwing a KeyError if the entity didn't have the Component as it wasn't guarded by a check or a default value:

return _entities[entity].pop(component_type)

Since the default for a non-extant Component type was to return None, I just added that default value to pop():

return _entities[entity].pop(component_type, None)

@benmoran56
Copy link
Copy Markdown
Owner

Thanks @mfeif, not sure how that one got missed!

@benmoran56 benmoran56 merged commit a4e56d8 into benmoran56:master May 14, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants