Fix bug where deletes from the environment were not removed from the task data as well

This commit is contained in:
Jon Herron 2023-02-09 09:45:31 -05:00
parent 03d163b1e0
commit ffb468d6bb
1 changed files with 7 additions and 0 deletions

View File

@ -207,6 +207,13 @@ class NonTaskDataBasedScriptEngineEnvironment(BasePythonScriptEngineEnvironment)
self.state.update(context) self.state.update(context)
exec(script, self.state) # noqa exec(script, self.state) # noqa
# since the task data is not directly mutated when the script executes, need to determine which keys
# have been deleted from the environment and remove them from task data if present.
context_keys_to_drop = context.keys() - self.state.keys()
for key_to_drop in context_keys_to_drop:
context.pop(key_to_drop)
self.state = self._user_defined_state(external_methods) self.state = self._user_defined_state(external_methods)
# the task data needs to be updated with the current state so data references can be resolved properly. # the task data needs to be updated with the current state so data references can be resolved properly.