Skip to content

fix(doctor): use context manager and errors=replace in inline python in ods-doctor.sh - #2820

Open
vaibhavsrv wants to merge 1 commit into
Osmantic:mainfrom
vaibhavsrv:fix/ods-doctor-load-capability-profile-encoding
Open

fix(doctor): use context manager and errors=replace in inline python in ods-doctor.sh#2820
vaibhavsrv wants to merge 1 commit into
Osmantic:mainfrom
vaibhavsrv:fix/ods-doctor-load-capability-profile-encoding

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Problem

In ods/scripts/ods-doctor.sh, inline Python helper reads capability profiles using bare json.load(open(path, "r", encoding="utf-8")). Leaving the file handle open without a context manager risks resource leaks on long-running diagnostic checks. Furthermore, if non-UTF-8 characters exist in custom capability profile files, open(..., encoding="utf-8") raised an uncaught UnicodeDecodeError.

Fix

Update inline Python in ods-doctor.sh to use a with open(path, "r", encoding="utf-8", errors="replace") as f: context manager.

Verification

Ran bash -n ods/scripts/ods-doctor.sh (passed cleanly). git diff --check passed cleanly.

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.

1 participant