Skip to content

[doc] Explain ConfigParser 'valid section name' and .SECTCRE #65122

Closed

Description

@miloskomarcevic
BPO 20923
Nosy @terryjreedy, @vstinner, @bitdancer, @ambv, @xflr6, @spaceone, @miss-islington, @iritkatriel, @Vidhyavinu
PRs
  • bpo-20923 : [doc] Explain ConfigParser 'valid section name' #31359
  • bpo-20923 : [doc] Explain ConfigParser 'valid section name' and .SECTCRE #31413
  • [3.10] bpo-20923 : [doc] Explain ConfigParser 'valid section name' and .SECTCRE (GH-31413) #31506
  • [3.9] bpo-20923 : [doc] Explain ConfigParser 'valid section name' and .SECTCRE (GH-31413) #31507
  • 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 = 'https://github.com/terryjreedy'
    closed_at = <Date 2022-02-22.18:46:35.431>
    created_at = <Date 2014-03-14.14:21:45.867>
    labels = ['easy', '3.9', '3.10', '3.11', 'type-feature', 'docs']
    title = "[doc] Explain ConfigParser 'valid section name' and .SECTCRE"
    updated_at = <Date 2022-02-22.18:46:35.431>
    user = 'https://bugs.python.org/miloskomarcevic'

    bugs.python.org fields:

    activity = <Date 2022-02-22.18:46:35.431>
    actor = 'iritkatriel'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2022-02-22.18:46:35.431>
    closer = 'iritkatriel'
    components = ['Documentation']
    creation = <Date 2014-03-14.14:21:45.867>
    creator = 'miloskomarcevic'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 20923
    keywords = ['patch', 'easy']
    message_count = 23.0
    messages = ['213554', '213609', '213678', '213687', '234954', '255263', '255269', '255277', '255278', '255279', '255281', '255304', '255325', '255368', '255369', '412197', '413270', '413271', '413292', '413727', '413734', '413738', '413739']
    nosy_count = 12.0
    nosy_names = ['terry.reedy', 'vstinner', 'r.david.murray', 'docs@python', 'lukasz.langa', 'python-dev', 'miloskomarcevic', 'xflr6', 'spaceone', 'miss-islington', 'iritkatriel', 'vidhya']
    pr_nums = ['31359', '31413', '31506', '31507']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue20923'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. miloskomarcevic commented on Mar 14, 2014

      miloskomarcevicmannequin
      MannequinAuthor

      It would be good if ConfigParser supported angled brackets in section names by being greedy when parsing.

      For example, section:

      [Test[2]_foo]

      gets parsed as:

      Test[2

    2. terryjreedy commented on Mar 15, 2014

      @terryjreedy
      Member

      This is invalid as a bug report, unless one considers that the presence of '_foo]' on the same line should have raised an exception. As an enhancement request, I think it should be rejected.

      ConfigParser configuration language is based on msdos/windows .ini files. Similar files are used on windows. "A configuration file consists of sections, each led by a [section] header," That and "The section name appears on a line by itself, in square brackets ([ and ])." from
      https://en.wikipedia.org/wiki/.ini#Sections
      mark [] as delimiters. I am rather sure that no other language/system allows square brackets in the section name. If you know differently, please present evidence. Unescaped delimiters are generally not allowed between delimiters unless there is a semantic reason to have nesting, and there is not one here. Parentheses, angle brackets, and curly brackets (and more from the rest of Unicode) are available to use. The request here is similar to asking that
      'abc'cd'
      be parsed as one string. Parsing nested constructs is much more complicated than parsing flat constructs.

    3. changed the title [-]ConfigParser should be greedy when parsing section name[/-] [+]ConfigParser should nested [] in section names.[/+] on Mar 15, 2014
    4. miloskomarcevic commented on Mar 15, 2014

      miloskomarcevicmannequin
      MannequinAuthor

      Thanks for the exhaustive explanation.

      I did however come across a proprietary application that stores it's configuration in an INI like file that exhibits this corner case behaviour with section names, hence the suggestion for enhancement.

    5. terryjreedy commented on Mar 15, 2014

      @terryjreedy
      Member

      I see. Perhaps it uses a proprietary .ini reader ;-).

    6. xflr6 commented on Jan 29, 2015

      xflr6mannequin
      Mannequin

      If this is the intended behaviuour, I guess ConfigParser should warn the user if he supplies a section name with a ']' (prevent failed roundtrips).

      See http://bugs.python.org/issue23301

      The current behaviour looks like the opposite of Postel's law.

    7. spaceone commented on Nov 24, 2015

      spaceonemannequin
      Mannequin

      IMHO your rejection is stupid. User input should always be validated.

      At least a ValueError should be raised if add_section() is called with a string containing ']\x00\n['. As this will always create a broken configuration.

      Otherwise ConfigParser cannot be used to write new config files without having deeper knowledge about the implementation.

    8. bitdancer commented on Nov 24, 2015

      @bitdancer
      Member

      The enhancement request was rejected. At this point I think it would be better to open a new bug requesting that an error be raised if the supplied section name contains a ']'. The question there is if there are backward compatibility issues. That can be discussed on the new issue you open.

    9. terryjreedy commented on Nov 24, 2015

      @terryjreedy
      Member

      Sebastian: you have it backwards. A paraphrase of Postel's recommendation (calling it a Law is wrong) is 'accept dirty data, emit clean data'. This is the current behavior. See https://en.wikipedia.org/wiki/Robustness_principle. This article also explains the opposite viewpoint, that dirty data should be rejected, as SpaceOne is suggesting.

      SpaceOne: unless it is your intention to discourage people from volunteering their time to respond to issues raised on the tracker, you should read what they write more carefully and think more carefully about how you express your opinions. If you really want a ValueError here, open an new enhancement issue for 3.6.

    10. added
      type-featureA feature request or enhancement
      and removed
      type-bugAn unexpected behavior, bug, or error
      on Nov 24, 2015
    11. spaceone commented on Nov 24, 2015

      spaceonemannequin
      Mannequin

      Sorry about that!
      I created http://bugs.python.org/issue25723.

    12. xflr6 commented on Nov 24, 2015

      xflr6mannequin
      Mannequin

      Terry: I am not so sure about that interpretation. Do we agree that the INI-files are the data/message? ConfigParser refuses to accept dirty INI-Files (with ']' in section names) but will produce this kind of files.
      I we see the arguments given to ConfigParser as data/message, it does indeed accept dirty data as you say, but still it does not emit clean one in that case, right?

    13. 13 remaining items

    14. iritkatriel commented on Jan 31, 2022

      @iritkatriel
      Member
    15. changed the title [-]Explain ConfigParser 'valid section name' and .SECTCRE[/-] [+][doc] Explain ConfigParser 'valid section name' and .SECTCRE[/+] on Jan 31, 2022
    16. Vidhyavinu commented on Feb 14, 2022

      Vidhyavinumannequin
      Mannequin

      I am newbie to Python developer group and have the document source build and compiled successfully.

      Is this issue updated in the document.
      I would like to work on this if this is not closed.
      Please let me know.

      Thanks

    17. iritkatriel commented on Feb 14, 2022

      @iritkatriel
      Member

      It’s still open. Go for it.

    18. Vidhyavinu commented on Feb 15, 2022

      Vidhyavinumannequin
      Mannequin

      Thanks.
      A pull request is created at #31359.

    19. iritkatriel commented on Feb 22, 2022

      @iritkatriel
      Member

      New changeset bba8008 by vidhya in branch 'main':
      bpo-20923 : [doc] Explain ConfigParser 'valid section name' and .SECTCRE (GH-31413)
      bba8008

    20. miss-islington commented on Feb 22, 2022

      @miss-islington
      Contributor

      New changeset a7af34d by Miss Islington (bot) in branch '3.10':
      [3.10] bpo-20923 : [doc] Explain ConfigParser 'valid section name' and .SECTCRE (GH-31413) (GH-31506)
      a7af34d

    21. miss-islington commented on Feb 22, 2022

      @miss-islington
      Contributor

      New changeset 2387aea by Miss Islington (bot) in branch '3.9':
      [3.9] bpo-20923 : [doc] Explain ConfigParser 'valid section name' and .SECTCRE (GH-31413) (GH-31507)
      2387aea

    22. iritkatriel commented on Feb 22, 2022

      @iritkatriel
      Member

      Thank you @Vidhya!

    23. 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

    Labels

    3.10 (EOL)end of life3.11only security fixes3.9 (EOL)end of lifedocsDocumentation in the Doc direasytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions