Conversation
…e field. defaults was stored by reference, so mutating the caller's dict (or leaving a DictConfigurator ConvertingDict in place) could change later log output. Copy it the same way as rename_fields and static_fields. A string reserved_attrs value is a Sequence of characters, so wrap it as a single field name.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
rename_fieldsandstatic_fieldsare already copied on construction so DictConfiguratorext:///cfg://prefixes convert (ConvertingDict only converts on__getitem__) and so later mutation of the caller's dict cannot change formatter state.defaultswas stored by reference, so it missed both of those guarantees.reserved_attrsis typed asSequence[str]. Astris a sequence of characters, soreserved_attrs="filename"reserved the lettersf,i,l,e,n,a,minstead of the fieldfilename.Summary of changes
defaultsthe same way asrename_fieldsandstatic_fields.reserved_attrsvalue as a single field name.defaults, and a stringreserved_attrs.Follow-up to the DictConfigurator copying in #45;
defaultswas enabled in 3.2 but was not copied.How tested
pytest tests(88 passed), including the new cases intests/test_formatters.pyandtests/test_dictconfig.py.black --check src tests