fix: keep a non-UTF-8 config.ini intact after PR #130 - #144
Merged
Merged
Conversation
PR #130 made the LLM, Ollama, vendor and image-generation settings read config.ini as strict UTF-8. A config.ini written earlier in the locale codec (cp1251, cp949, gbk) with non-ASCII text then fails to read, the writer carries on with an empty parser and rewrites the file with only its own section: the window position, the GitHub token and the prompt are lost. config_store already had the locale-codec fallback; the other readers did not use it. - config_store: rename _read_text to read_config_text (no underscore names in this project) and use it from every config reader - ai_backends, github_notify, llm_prompt, llm_vendors, main, settings_ui, shop_api: read through config_store.read_config_text; catch OSError, which ConfigParser.read() used to swallow, instead of the UnicodeDecodeError the shared reader no longer raises - tests: a cp1251 config.ini keeps every section through each save - CHANGELOG: Unreleased entries for PR #130 and for this fix
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.
Summary
PR #130 (merged into
0.1.37) made the LLM, Ollama, vendor and image-generation settings readconfig.inias strict UTF-8. On a Windows install whoseconfig.iniwas written earlier in the locale codec (cp1251, cp949, gbk) and holds non-ASCII text, the first save after the upgrade fails to read the file, carries on with an empty parser and rewritesconfig.iniwith only its own section. Reproduced on #130: a cp1251 file with[window],[github]and[generation]is left with only[llm]aftersave_llm_enabled(True).config_storealready had the locale-codec fallback; the other readers did not use it.config_store:_read_textrenamed toread_config_text(no underscore-prefixed names in this project).ai_backends,github_notify,llm_prompt,llm_vendors,main,settings_ui,shop_api: everyconfig.iniread goes throughconfig_store.read_config_text; the handlers catchOSError(whichConfigParser.read()used to swallow) instead of theUnicodeDecodeErrorthe shared reader no longer raises.tests/test_legacy_config_keeps_its_sections.py: a cp1251config.inikeeps every section through each of the four savers.Unreleasedsection with entries for PR Two small correctness fixes: file permissions, and text encoding #130 and for this fix.Test plan
0.1.37without this fix (4 failed) and passes with itruff check mycat testscleanpytest --forked --timeout=60 --timeout-method=thread) passes locally