fix(extensions): use explicit UTF-8 encoding when reading manifest YAML#2370
Open
Quratulain-bilal wants to merge 1 commit intogithub:mainfrom
Open
fix(extensions): use explicit UTF-8 encoding when reading manifest YAML#2370Quratulain-bilal wants to merge 1 commit intogithub:mainfrom
Quratulain-bilal wants to merge 1 commit intogithub:mainfrom
Conversation
On Windows, Python's open() defaults to the system locale encoding (e.g., GBK on Chinese Windows), which causes UnicodeDecodeError when extension.yml or preset.yml contains non-ASCII content such as Chinese characters in description fields. Add encoding='utf-8' to ExtensionManifest._load_yaml and PresetManifest._load_yaml so manifests are read consistently across platforms. Fixes github#2325
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
Fixes #2325 —
specify extension addcrashes on Windows withUnicodeDecodeError: 'gbk' codec can't decode byte ...when
extension.yml/preset.ymlcontains non-ASCII content (e.g., Chinese indescription).Root cause
ExtensionManifest._load_yaml(src/specify_cli/extensions.py:142) andPresetManifest._load_yaml(
src/specify_cli/presets.py:139) callopen(path, 'r')without explicit encoding. On Windows, Python uses the systemlocale (GBK on Chinese Windows), which fails on UTF-8 manifests.
Fix
Add
encoding='utf-8'to bothopen()calls — matching convention already used inintegrations/catalog.py:449,workflows/engine.py:63, and everyread_text(encoding="utf-8")callsite.Test plan