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 replaces unnamed section on every read call #127096

Open
PalmtopTiger opened this issue Nov 21, 2024 · 2 comments
Open

ConfigParser replaces unnamed section on every read call #127096

PalmtopTiger opened this issue Nov 21, 2024 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@PalmtopTiger
Copy link

PalmtopTiger commented Nov 21, 2024

Bug report

Bug description:

from configparser import ConfigParser

config = ConfigParser(allow_unnamed_section=True)
config.read(['first.ini', 'second.ini'])

# now the unnamed section contains values ​​only from the second file:
print(config._sections)
# {
# <UNNAMED_SECTION>: {'second_unnamed_option1': '1', 'second_unnamed_option2': '2'},
# 'first_section': {'first_section_option1': '1', 'first_section_option2': '2'},
# 'second_section': {'second_section_option1': '1', 'second_section_option2': '2'}
# }

I think the problem is somewhere here. The unnamed section is recreated on every call.
first.ini.txt
second.ini.txt

CPython versions tested on:

3.13

Operating systems tested on:

Windows

@PalmtopTiger PalmtopTiger added the type-bug An unexpected behavior, bug, or error label Nov 21, 2024
@sobolevn
Copy link
Member

Please, provide the contents of first.ini and second.ini, so it would be easier to reproduce the issue.

@PalmtopTiger
Copy link
Author

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants