This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients BreamoreBoy, docs@python, lukasz.langa, miloskomarcevic, r.david.murray, spaceone, terry.reedy, xflr6
Date 2015-11-24.23:37:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1448408220.9.0.150519052999.issue20923@psf.upfronthosting.co.za>
In-reply-to
Content
Discussion continues because my close message was, I now realize, incomplete and therefore unsatisfying.  Ditto for the doc.  So I complete my close message here and reopen issue to augment the doc.

The discussion has so far has glossed over the key question: "What is a legal section name?"  Pulling the answer from the doc was a challenge. It uses 'legal section name', once, as if one should already know. Reading further, I found the answer: there is no (fixed) answer!

The legal section name for a particular parser is determined by its .SECTCRE class attribute.
'''configparser.SECTCRE
    A compiled regular expression used to parse section headers. The default matches [section] to the name "section".'''  (This neglects to say whether the closing ']' is the first or last ']' on the line after the opening '['.) A non-verbose version of the default is
re.compile(r"\[(?P<header>[^]]+)\]").

I propose adding near the top of the doc:
"By default, a legal section name can be any string that does not contain '\n' or ']'.  To change this, see configparser.SECTCRE."

So my response to Miloš should have been to set SECTCRE to something like p below.

>>> p = re.compile(r"\[(?P<header>.*)\]")
>>> m = p.search("[Test[2]_foo]")
>>> m.group('header')
'Test[2]_foo'

Additional note: Postel's principle was formulated for internet protocols, which .ini files are not.  In any case, it is not a Python design principle.  Neither is "always check user input", which amounts to 'look before you leap'.  So I will not debate these. However, "Errors should never pass silently." is #10 on the Zen of Python ('import this') and that I do attend to.
History
Date User Action Args
2015-11-24 23:37:00terry.reedysetrecipients: + terry.reedy, r.david.murray, docs@python, BreamoreBoy, lukasz.langa, miloskomarcevic, xflr6, spaceone
2015-11-24 23:37:00terry.reedysetmessageid: <1448408220.9.0.150519052999.issue20923@psf.upfronthosting.co.za>
2015-11-24 23:37:00terry.reedylinkissue20923 messages
2015-11-24 23:37:00terry.reedycreate