traitlets icon indicating copy to clipboard operation
traitlets copied to clipboard

Why prematurely clone `self.config` in `update_config()`?

Open ankostis opened this issue 8 years ago • 5 comments

In Configurable.update_config()#L214 https://github.com/ipython/traitlets/blob/4da01bfdd675783ab64a21df015e49378d91cbd2/traitlets/config/configurable.py#L206-L218 the config attribute is deep-cloned before _load_config() has the chance to validate config-values. In case of trait-errors, this clone is wasted.

Was that on purpose?

ankostis avatar Aug 19 '17 16:08 ankostis

As described in the comment you pasted, for backward-compatibility the object must not be modified at all. The modifications in _load_config are modifications.

minrk avatar Aug 20 '17 08:08 minrk

But _load_config () does not modify the config object, It merely passes its values into traits, no?

Note, i didn't paste any code, that's a new feature of GitHub: https://twitter.com/github/status/897879057034993665

ankostis avatar Aug 20 '17 08:08 ankostis

It shouldn't matter. This assignment is purely a backward-compatibility artifact. Any code that is sensitive to where this assignment occurs should change.

minrk avatar Aug 21 '17 14:08 minrk

I'm just asking to make sure that it is not for the cached values in loader.LazyConfigValue._value, is it?

ankostis avatar Aug 21 '17 14:08 ankostis

Clarification: I only discovered this part AFTER my last comment above.

ankostis avatar Aug 21 '17 14:08 ankostis