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

Don't panic (on general section for empty ini) #88

Merged
merged 2 commits into from
Mar 26, 2022

Conversation

sirhcel
Copy link
Contributor

@sirhcel sirhcel commented Mar 26, 2022

  • Calling general_section() and general_section_mut() on new ini or one loaded from an empty file panics as shown by c2ccbef
  • This panic is neither documented or what I expect here
    • Doesn't an empty ini (file) always contain an empty general section?
    • Which is a corner case but it matters for general_section() and general_section_mut()
  • This PR adds an empty general section via Ini::default()
    • So an in instance will always have a general section
    • This general section is empty by default
    • This approach covers all paths for getting an ini instance: new(), default(), load_...(), and so on

sirhcel added 2 commits March 26, 2022 13:04
When creating a new ini or loading it from an input which contains no
actual entries but empty lines for the general section, calling
general_section and general_section_mut panics. This is not documented
nor do I expect this behavior: Isn't an empty file equivalent to an
empty general section? And from this perspective, calls to
general_section or general_section_mut should not panic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants