Skip to content

ConfigParser: add_section('DEFAULT') causes duplicate sections. #46114

Closed

Description

@tlesher
mannequin
BPO 1781
Nosy @gvanrossum, @facundobatista, @tiran, @humitos
Files
  • cfgparser.diff
  • NEWS.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2008-02-23.12:47:04.174>
    created_at = <Date 2008-01-10.02:42:49.018>
    labels = ['easy', 'type-bug', 'library']
    title = "ConfigParser: add_section('DEFAULT') causes duplicate sections."
    updated_at = <Date 2008-02-23.12:47:04.168>
    user = 'https://bugs.python.org/tlesher'

    bugs.python.org fields:

    activity = <Date 2008-02-23.12:47:04.168>
    actor = 'facundobatista'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-02-23.12:47:04.174>
    closer = 'facundobatista'
    components = ['Library (Lib)']
    creation = <Date 2008-01-10.02:42:49.018>
    creator = 'tlesher'
    dependencies = []
    files = ['9118', '9492']
    hgrepos = []
    issue_num = 1781
    keywords = ['patch', 'easy']
    message_count = 7.0
    messages = ['59652', '59653', '59666', '59679', '59680', '62722', '62724']
    nosy_count = 6.0
    nosy_names = ['gvanrossum', 'facundobatista', 'draghuram', 'christian.heimes', 'tlesher', 'humitos']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue1781'
    versions = ['Python 2.6']

    Activity

    1. tlesher commented on Jan 10, 2008

      tleshermannequin
      MannequinAuthor

      ConfigParser doesn't prevent "manually" adding a section named DEFAULT;
      however, doing so creates a duplicate, inaccessible [DEFAULT] section in
      the config file:
      ----

      >>> import sys, ConfigParser
      >>> c = ConfigParser.ConfigParser()
      >>> c.add_section('DEFAULT')
      >>> c.write(sys.stdout)
      [DEFAULT]
      
      >>> c.set('DEFAULT', 'color', 'yellow')
      >>> c.write(sys.stdout)
      [DEFAULT]
      color = yellow

      [DEFAULT]

      ----
      It seems that the correct thing to do would be to disallow
      add_section('DEFAULT').

    2. added
      stdlib
      type-bug
      on Jan 10, 2008
    3. gvanrossum commented on Jan 10, 2008

      @gvanrossum
      Member

      Care to provide a patch?

      Otherwise this may be a good bug day candidate. The next one's Jan 19.

    4. tiran commented on Jan 10, 2008

      @tiran
      Member

      It's an easy task for the bug day unless you can provide a patch and an
      unit test earlier.

    5. draghuram commented on Jan 10, 2008

      draghurammannequin
      Mannequin

      Please see cfgparser.diff for the fix. It has tests and doc change.

    6. draghuram commented on Jan 10, 2008

      draghurammannequin
      Mannequin

      I should add that the patch disallows not only 'DEFAULT' but all other
      variants such as "Default" and "default". I am not entirely sure if my
      description of this behaviour as "DEFAULT or any of it's
      case-insensitive variants".

    7. humitos commented on Feb 23, 2008

      humitosmannequin
      Mannequin

      I tested the patch and works very well. I modified "Misc/NEWS" file
      beacuse the change wasn't reported and I uploaded diff file
      (NEWS.diff).

    8. facundobatista commented on Feb 23, 2008

      @facundobatista
      Member

      Applied in r60976. Thank you all!

    9. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      easystdlibtype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions