Skip to content

v4.2

Latest

Choose a tag to compare

@github-actions github-actions released this 05 Dec 11:47
  • Keep existing options and sections intact when assigning a replacement that
    is already attached to another container and raises AlreadyAttachedError,
    PR #189
  • Behavior change: Removing an option or section with del, pop(),
    popitem(), remove_option() or remove_section() detaches it, as
    clear() and detach() already do, so it can be added to another section or
    document instead of raising AlreadyAttachedError. Like any detached block, it
    no longer reaches its former parent: Option.key, Option.section,
    Section.document and reading or changing the options of a removed section,
    e.g. section["key"], in, get(), set() or to_dict(), raise
    NotAttachedError until it is added again. Option.value,
    Option.raw_key and Section.name keep working. A section popped from
    ConfigParser cannot be read either, so read it before removing it
    (follow-up to PR #180), PR #188
  • Behavior change: updater[key] = section raises a ValueError if the
    section's name is not key also when it replaces an existing section, as it
    already did when it adds one. Before, updater["a"] = updater["b"] put the same
    section twice into the document, and a copied or detached section replaced
    [a] under its own name, so updater["a"] was gone afterwards. ConfigParser
    copies the options of b into a instead; to do the same, assign a
    copy.deepcopy of b renamed to a. The error message now says "section
    name" instead of "option key", PR #191
  • update_file() encodes the configuration before it opens the file, so a value
    that the file's encoding cannot represent raises UnicodeEncodeError and leaves
    the file untouched instead of emptying it (follow-up to PR #165), PR #190
  • Behavior change: items(section) raises NoSectionError instead of
    KeyError for a missing section, like ConfigParser.items() and the other
    methods that take a section name, e.g. options(), get() and set(),
    PR #193
  • Renaming an option by setting Option.key keeps its original lines and only
    replaces the key, so the continuation lines of a multi-line value stay indented
    instead of turning into new options. A renamed option also keeps its delimiter
    spacing, e.g. opt=42 becomes new=42 instead of new = 42, issue #195
  • set() leaves the section unchanged when it rejects the value, e.g. a multi-line
    string, or when iterating over the values raises. Before, it had already added the
    new option without a value and could add a newline to the line before it, PR #197
  • Behavior change: section[key] = value and the builder's option(key, value) raise AssignMultilineValueError for a multi-line string also when they
    create a new option, as assigning it to an existing option already does. Before,
    the string was written as is, which gave an invalid file unless its continuation
    lines were indented. Use set(key, lines) or Option.set_values() for a
    multi-line value, PR #202
  • Use the configured optionxform in validate_format(), write() and
    update_file(). Case-sensitive options can be saved without false duplicate
    errors, and duplicates introduced by custom normalization are rejected
    (follow-up to PR #69), PR #203
  • Behavior change: Reading a section with two options whose keys are equal after
    optionxform, e.g. Key and key with the default lowercase
    transformation, raises DuplicateOptionError like ConfigParser. Before, only
    options with the same spelling were duplicates, so such a file was read, but
    write() and update_file() refused to save it. Options keep the spelling of
    their keys as before, PR #204