fix(configfile): fix bugs, optimize parser, add support for normal an inline comments and add unit tests#198
Open
gmmcosta15 wants to merge 3 commits intodevfrom
Open
fix(configfile): fix bugs, optimize parser, add support for normal an inline comments and add unit tests#198gmmcosta15 wants to merge 3 commits intodevfrom
gmmcosta15 wants to merge 3 commits intodevfrom
Conversation
… inline comments and add unit tests loadWidget: fix bug that would result in a crash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request intruduces:
_parse_file: separator normalisation was replacing every:and=in a line instead of just the first one, silently mangling URLs, tokens, and section names with colonsget(),getint(),getfloat(),getboolean()default-handling: missing options with no default now raiseNoOptionErrorinstead of returningSentinel.MISSING;get()no longer passes the fallback through the parseradd_option(value=None)writing the literal string"None"instead of a value-less option line%-style, addexc_info=Trueand file path tosave_configurationerror, add exception chaining (from e) throughoutMotivation
The
configfile modulehad several subtle parsing bugs and inconsistent behaviors that could corrupt configuration values (e.g., URLs, tokens, or section names) and return incorrect results in some edge cases.This PR stabilizes the module by fixing multiple correctness issues, tightening error handling, and improving logging. It also refactors parts of the parser to simplify internal tracking and avoid repeated regex compilation.
To prevent regressions and make future changes safer, a comprehensive unit test suite (80 tests) was added, covering parsing behavior, configuration access methods, lifecycle operations, and concurrency aspects.
Tests
tests/util/test_configfile_unit.py:80 unit tests. Covers parsing, comment handling, deduplication, all read methods, get_section view sharing, add/update/ save lifecycle, get_configparser factory, RLock reentrancy, thread safety, and stale-view-after-reload.