Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigParser does not accept "No value" reversely to the doc #89380

Closed
sbougnoux mannequin opened this issue Sep 16, 2021 · 9 comments
Closed

ConfigParser does not accept "No value" reversely to the doc #89380

sbougnoux mannequin opened this issue Sep 16, 2021 · 9 comments
Labels
3.8 only security fixes 3.9 only security fixes docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@sbougnoux
Copy link
Mannequin

sbougnoux mannequin commented Sep 16, 2021

BPO 45217
Nosy @ambv, @pablogsal, @miss-islington, @sobolevn
PRs
  • bpo-45217: adds note that allow_no_value in configparser is optional #28396
  • [3.9] bpo-45217: adds note that allow_no_value in configparser is optional (GH-28396) #28416
  • [3.10] bpo-45217: adds note that allow_no_value in configparser is optional (GH-28396) #28418
  • 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 2021-09-17.13:11:28.191>
    created_at = <Date 2021-09-16.08:51:18.678>
    labels = ['3.8', 'type-bug', 'library', '3.9', 'docs']
    title = 'ConfigParser does not accept "No value" reversely to the doc'
    updated_at = <Date 2021-10-04.19:18:41.739>
    user = 'https://bugs.python.org/sbougnoux'

    bugs.python.org fields:

    activity = <Date 2021-10-04.19:18:41.739>
    actor = 'pablogsal'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2021-09-17.13:11:28.191>
    closer = 'lukasz.langa'
    components = ['Demos and Tools', 'Documentation', 'Library (Lib)']
    creation = <Date 2021-09-16.08:51:18.678>
    creator = 'sbougnoux'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45217
    keywords = ['patch']
    message_count = 9.0
    messages = ['401932', '401983', '402005', '402026', '402036', '402039', '402049', '402050', '403150']
    nosy_count = 6.0
    nosy_names = ['docs@python', 'lukasz.langa', 'pablogsal', 'miss-islington', 'sobolevn', 'sbougnoux']
    pr_nums = ['28396', '28416', '28418']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45217'
    versions = ['Python 3.8', 'Python 3.9']

    @sbougnoux
    Copy link
    Mannequin Author

    sbougnoux mannequin commented Sep 16, 2021

    Just the simple following config crashes

    """
    [Bug]
    Here
    """

    Hopefully using "Here=" solves the issue, but the doc claims it shall work.
    https://docs.python.org/3.8/library/configparser.html?highlight=configparser#supported-ini-file-structure

    Save the config in "bug.ini", then write (it will raise an exception)
    """
    from configparser import ConfigParser
    ConfigParser().read('bug.ini')
    """

    @sbougnoux sbougnoux mannequin added 3.8 only security fixes 3.9 only security fixes labels Sep 16, 2021
    @sbougnoux sbougnoux mannequin assigned docspython Sep 16, 2021
    @sbougnoux sbougnoux mannequin added docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error 3.8 only security fixes 3.9 only security fixes labels Sep 16, 2021
    @sbougnoux sbougnoux mannequin assigned docspython Sep 16, 2021
    @sbougnoux sbougnoux mannequin added docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 16, 2021
    @sobolevn
    Copy link
    Member

    Try this:

    from configparser import ConfigParser
    ConfigParser(allow_no_value=True).read('bug.ini')
    

    It should work! :)

    But, the docs are missing this config value here (which caused this issue):

    Values can be omitted, in which case the key/value delimiter may also be left out.

    https://github.com/python/cpython/blame/f4b94b1f57827083990272b5f282aa1493ae2bf4/Doc/library/configparser.rst#L264

    I will update the docs.

    @sbougnoux
    Copy link
    Mannequin Author

    sbougnoux mannequin commented Sep 17, 2021

    Thanks for your prompt answer. Don't you think it should be the default? It seems like unneeded precision. Just if you want to check one don't miss a value, but in that case, one can use 'allow_no_value=False'.

    @ambv
    Copy link
    Contributor

    ambv commented Sep 17, 2021

    No, it shouldn't be the default. It never was before (this is a library that we've maintained for 20+ years now) and changing it now would mean that existing applications would stop validating their configuration in the way they did up to now.

    .ini files are unfortunately very imprecisely specified but they are *mostly* interoperable between applications. Changing defaults at this point is therefore out of the question.

    @ambv
    Copy link
    Contributor

    ambv commented Sep 17, 2021

    New changeset cb07838 by Nikita Sobolev in branch 'main':
    bpo-45217: adds note that allow_no_value in configparser is optional (GH-28396)
    cb07838

    @ambv
    Copy link
    Contributor

    ambv commented Sep 17, 2021

    New changeset 3ea1c4b by Miss Islington (bot) in branch '3.9':
    bpo-45217: adds note that allow_no_value in configparser is optional (GH-28396) (GH-28416)
    3ea1c4b

    @ambv
    Copy link
    Contributor

    ambv commented Sep 17, 2021

    New changeset a10726d by Miss Islington (bot) in branch '3.10':
    bpo-45217: adds note that allow_no_value in configparser is optional (GH-28396) (GH-28418)
    a10726d

    @ambv
    Copy link
    Contributor

    ambv commented Sep 17, 2021

    Thanks for the patch, Nikita! ✨ 🍰 ✨

    @ambv ambv closed this as completed Sep 17, 2021
    @ambv ambv closed this as completed Sep 17, 2021
    @pablogsal
    Copy link
    Member

    New changeset c4e9ef1 by Pablo Galindo (Miss Islington (bot)) in branch '3.10':
    bpo-45217: adds note that allow_no_value in configparser is optional (GH-28396) (GH-28418)
    c4e9ef1

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants