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._read doesn't join multi-line values collected while reading if a ParsingError occured #68330

Closed
fhoech mannequin opened this issue May 7, 2015 · 10 comments
Assignees
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@fhoech
Copy link
Mannequin

fhoech mannequin commented May 7, 2015

BPO 24142
Nosy @ned-deily, @ambv, @serhiy-storchaka
PRs
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • ConfigParser.py.patch
  • 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/ambv'
    closed_at = <Date 2016-11-26.22:06:53.090>
    created_at = <Date 2015-05-07.15:54:46.878>
    labels = ['3.7', 'type-bug', 'library']
    title = "ConfigParser._read doesn't join multi-line values collected while reading if a ParsingError occured"
    updated_at = <Date 2017-03-31.16:36:32.996>
    user = 'https://bugs.python.org/fhoech'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:32.996>
    actor = 'dstufft'
    assignee = 'lukasz.langa'
    closed = True
    closed_date = <Date 2016-11-26.22:06:53.090>
    closer = 'lukasz.langa'
    components = ['Library (Lib)']
    creation = <Date 2015-05-07.15:54:46.878>
    creator = 'fhoech'
    dependencies = []
    files = ['39312']
    hgrepos = []
    issue_num = 24142
    keywords = ['patch']
    message_count = 10.0
    messages = ['242718', '242719', '242725', '272120', '281802', '281803', '281804', '281809', '281839', '281846']
    nosy_count = 5.0
    nosy_names = ['ned.deily', 'lukasz.langa', 'python-dev', 'serhiy.storchaka', 'fhoech']
    pr_nums = ['552']
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue24142'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    @fhoech
    Copy link
    Mannequin Author

    fhoech mannequin commented May 7, 2015

    If a ParsingError occurs while reading a config file, the multi-line values collected while reading will never be joined because the error is raised before this can happen. This leads to very unexpected results, e.g. consider the following config.ini:

    [DEFAULT]
    test = test
    invalid

    >> cfg = ConfigParser.ConfigParser()
    >> cfg.read(['config.ini'])

    This will raise a ParsingError as expected. But the option values that were parsed without error are now all lists instead of strings:

    >>> cfg.get('DEFAULT', test')
    ['test']

    Patch attached.

    @fhoech fhoech mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels May 7, 2015
    @fhoech
    Copy link
    Mannequin Author

    fhoech mannequin commented May 7, 2015

    [Btw, you might want to fix the contributor agreement form - I can't sign it because it shows no text, so I don't know what I'm supposed to enter in the fields (Firefox 37.0.2)]

    @ned-deily
    Copy link
    Member

    [Thanks for the headsup about the contributor agreement form, now reported as https://github.com/python/pythondotorg/issues/747]

    @ambv ambv self-assigned this Sep 4, 2015
    @fhoech
    Copy link
    Mannequin Author

    fhoech mannequin commented Aug 7, 2016

    It seems this hasn't landed yet?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 26, 2016

    New changeset 40567b8e3478 by Łukasz Langa in branch '3.5':
    Fixes bpo-24142: [configparser] always join multiline values to not leave the parser in an invalid state
    https://hg.python.org/cpython/rev/40567b8e3478

    New changeset 306cfb866399 by Łukasz Langa in branch '3.6':
    Merge 3.5, fix for bpo-24142
    https://hg.python.org/cpython/rev/306cfb866399

    New changeset 876bee0bd0ba by Łukasz Langa in branch 'default':
    Merge 3.6, fix for bpo-24142
    https://hg.python.org/cpython/rev/876bee0bd0ba

    @ambv
    Copy link
    Contributor

    ambv commented Nov 26, 2016

    Thanks for your patch! As you can see, 2.7 is no longer touched as the codebases diverged. I'll release a 3.6 backport on PyPI sometime this weekend that you can use.

    @ambv ambv added the 3.7 (EOL) end of life label Nov 26, 2016
    @ambv ambv closed this as completed Nov 26, 2016
    @serhiy-storchaka
    Copy link
    Member

    Is this release critical for 3.6.0?

    @ned-deily
    Copy link
    Member

    After discussing this offline with Łukasz, I'm going to take the risk of allowing the non-conforming 3.6 checkin to remain in for 3.6.0.

    @fhoech
    Copy link
    Mannequin Author

    fhoech mannequin commented Nov 28, 2016

    Thanks for your patch! As you can see, 2.7 is no longer touched as the
    codebases diverged.

    Thanks, although I have to say it's a little bit unfortunate that Python
    2.7 will be left in a worse state than 2.6 where this bug did not exist.

    @serhiy-storchaka
    Copy link
    Member

    Would be nice to add Misc/NEWS entry for this patch.

    @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.7 (EOL) end of life 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