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.py do not allow leading (and trailing) space in values. #46055

Closed
msuchy mannequin opened this issue Dec 31, 2007 · 6 comments
Closed

ConfigParser.py do not allow leading (and trailing) space in values. #46055

msuchy mannequin opened this issue Dec 31, 2007 · 6 comments
Assignees
Labels
easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@msuchy
Copy link
Mannequin

msuchy mannequin commented Dec 31, 2007

BPO 1714
Nosy @akuchling, @tiran
Superseder
  • bpo-1524825: ConfigParser: accept leading whitespace on options+comments
  • Files
  • cfgparser_doublequotes_r61014.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/akuchling'
    closed_at = <Date 2010-07-10.05:41:57.548>
    created_at = <Date 2007-12-31.15:30:01.301>
    labels = ['easy', 'type-bug', 'library']
    title = 'ConfigParser.py do not allow leading (and trailing) space in values.'
    updated_at = <Date 2010-07-10.05:41:57.546>
    user = 'https://bugs.python.org/msuchy'

    bugs.python.org fields:

    activity = <Date 2010-07-10.05:41:57.546>
    actor = 'terry.reedy'
    assignee = 'akuchling'
    closed = True
    closed_date = <Date 2010-07-10.05:41:57.548>
    closer = 'terry.reedy'
    components = ['Library (Lib)']
    creation = <Date 2007-12-31.15:30:01.301>
    creator = 'msuchy'
    dependencies = []
    files = ['9523']
    hgrepos = []
    issue_num = 1714
    keywords = ['patch', 'easy']
    message_count = 6.0
    messages = ['59060', '59777', '60186', '62826', '66582', '66591']
    nosy_count = 7.0
    nosy_names = ['akuchling', 'draghuram', 'christian.heimes', 'schmir', 'quentin.gallet-gilles', 'msuchy', 'jonatasoliveira']
    pr_nums = []
    priority = 'low'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '1524825'
    type = 'behavior'
    url = 'https://bugs.python.org/issue1714'
    versions = ['Python 3.2']

    @msuchy
    Copy link
    Mannequin Author

    msuchy mannequin commented Dec 31, 2007

    I have some configuration params with leading space. And program
    (getmail4) which use ConfigParser.py. ConfigParser strip all leading
    (and trailing) spaces from values. This is very often the most wanted
    result. But if I want value with leading space I have no option to put
    it there.
    Therefore I suggest to optionaly write string value as
    key = "value"

    This patch will solve it (it is against my OS, sorry no chance to
    checkout svn).

    --- /usr/lib/python2.4/ConfigParser.py.orig     2007-12-31
    16:04:32.000000000 +0100
    +++ /usr/lib/python2.4/ConfigParser.py  2007-12-31 16:06:50.000000000 +0100
    @@ -472,6 +472,7 @@
                                 if pos != -1 and optval[pos-1].isspace():
                                     optval = optval[:pos]
                             optval = optval.strip()
    +                        optval = optval.strip('"')
                             # allow empty values
                             if optval == '""':
                                 optval = ''

    @msuchy msuchy mannequin added extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error labels Dec 31, 2007
    @tiran
    Copy link
    Member

    tiran commented Jan 12, 2008

    Please provide a patch against 2.6 with an unit test and documentation
    updates.

    @tiran tiran added easy stdlib Python modules in the Lib dir and removed extension-modules C modules in the Modules dir labels Jan 12, 2008
    @quentingallet-gilles
    Copy link
    Mannequin

    quentingallet-gilles mannequin commented Jan 19, 2008

    Attached patch contain the added behavior, some unit tests to validate
    it and updated documentation.

    @akuchling akuchling self-assigned this Feb 23, 2008
    @quentingallet-gilles
    Copy link
    Mannequin

    quentingallet-gilles mannequin commented Feb 23, 2008

    Here's an updated patch, taking in account akuchling and schmir suggestions.

    @jonatasoliveira
    Copy link
    Mannequin

    jonatasoliveira mannequin commented May 10, 2008

    The cfgparser_doublequotes_r61014.patch works for me.

    I disagree wrapping a double quoted string with another double quote, it's
    more elegant using single quote like python's string behavior, but I don't
    know if is acceptable for a .ini file.

    PS: Like Jeremy Thurgood said in msg66523, this is almost the same of bpo-1524825.

    @jonatasoliveira
    Copy link
    Mannequin

    jonatasoliveira mannequin commented May 10, 2008

    Btw, i ran all tests before write "works for me" message.

    @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
    easy 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