Skip to content

Make sure cached ECs don't get modifed #4818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

Flamefire
Copy link
Contributor

@Flamefire Flamefire commented Mar 17, 2025

The type that is cached is a dictionary containing the EasyConfig in the "ec" key. Hence we end up invoking dict.copy not ec.copy

This results in not making independent copies and hence modifications affect all references even those gotten later

Revert 3836140 which introduced the issue

Our current EasyConfig.copy method effectively parses the EasyConfig text again invoking e.g. the parse_hook again.

I guess __deepcopy__ needs to be more smart than this to not also miss attributes set after the construction. Hence I left that out and just used ec.copy() as was likely intended by the above commit. It just needs to be done on the EasyConfig instance while the dict itself can be deep-copied if it doesn't contain the easyconfig.

The `__deepcopy__` needs to be very generic to avoid misleading results
by not copying all (possibly changed) attributes.
So leave that alone and use `ec.copy()` on the `'ec'` key directly in
the cache code.
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.

1 participant