Skip to content

Comments included in values #55

Closed

Description

@jefferyto

I'm looking into updating the OpenWrt package for iniconfig (from 1.1.1 to 2.0.0), and when I try the example from the readme with 2.0.0 (using the example ini file) I get:

Python 3.11.4 (main, Aug  3 2023, 22:34:22) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import iniconfig
>>> ini = iniconfig.IniConfig("example.ini")
>>> ini['section1']['name1']
'value1  # comment'
>>> ini.get('section1', 'name1b', [], lambda x: x.split(","))
['value1', 'value2  # comment']
>>> ini.get('section1', 'notexist', [], lambda x: x.split(","))
[]
>>> [x.name for x in list(ini)]
['section1', 'section2']
>>> list(list(ini)[0].items())
[('name1', 'value1  # comment'), ('name1b', 'value1,value2  # comment')]
>>> 'section1' in ini
True
>>> 'inexistendsection' in ini
False
>>> 

Note that # comment is included with the value of name1 and the second value of name1b. This appears to differ from the output in the readme - is the above the expected/correct output?

Activity

  1. RonnyPfannschmidt commented on Aug 7, 2023

    @RonnyPfannschmidt
    Member

    I won't be able to get into this today, does the behavior replicate on a desktop python?

  2. jefferyto commented on Aug 7, 2023

    @jefferyto
    Author

    I won't be able to get into this today, does the behavior replicate on a desktop python?

    Yes, I get the same results in a venv on Ubuntu 23.04 (Python 3.11.4).

  3. RonnyPfannschmidt commented on Aug 7, 2023

    @RonnyPfannschmidt
    Member

    wow, seems like this is a allwinner, the bug got pulled in from the pylib codebase in 3ebb68c in 2016 by me

    now i gotta figure how that was added/missed in pylib as well
    this might end up being a 10 year missed bug

  4. RonnyPfannschmidt commented on Aug 7, 2023

    @RonnyPfannschmidt
    Member

    introduced in pytest-dev/py@ba38736 it seems

  5. RonnyPfannschmidt commented on Aug 7, 2023

    @RonnyPfannschmidt
    Member

    as far as i can tell it seems necessary to elevate this bug to a default feature and allow a "opt out" 😱

  6. RonnyPfannschmidt commented on Aug 7, 2023

    @RonnyPfannschmidt
    Member

    @jefferyto as far as i can tell now after research, the behavior you observe is indeed intended, but its introduction was a bit roundabout, a design decission is needed on how to change it now

  7. jefferyto commented on Aug 8, 2023

    @jefferyto
    Author

    Thanks for investigating - I'm not really a user of this module so I'm okay with whatever resolution is deemed appropriate.

  8. added a commit that references this issue on Oct 18, 2025
    e2d89f5
  9. added a commit that references this issue on Oct 19, 2025
    bdfec56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions