Skip to content

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

Closed

Description

@msuchy
mannequin
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']

    Activity

    1. msuchy commented on Dec 31, 2007

      msuchymannequin
      MannequinAuthor

      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 = ''
    2. added
      extension-modules
      type-bug
      on Dec 31, 2007
    3. tiran commented on Jan 12, 2008

      @tiran
      Member

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

    4. added
      stdlib
      and removed
      extension-modules
      on Jan 12, 2008
    5. quentingallet-gilles commented on Jan 19, 2008

      quentingallet-gillesmannequin
      Mannequin

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

    6. self-assigned this
      on Feb 23, 2008
    7. quentingallet-gilles commented on Feb 23, 2008

      quentingallet-gillesmannequin
      Mannequin

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

    8. jonatasoliveira commented on May 10, 2008

      jonatasoliveiramannequin
      Mannequin

      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.

    9. jonatasoliveira commented on May 10, 2008

      jonatasoliveiramannequin
      Mannequin

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

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

    easystdlibtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions