Skip to content

Commit 2b8532e

Browse files
oxesoftclaude
andauthored
Specify utf-8 encoding when reading module source files (#329)
* Specify utf-8 encoding when reading module source files Avoids reliance on the platform default locale when parsing imported module sources for matter base test class detection. Fixes #323 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Use Path.read_text instead of nested with-open block Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 35981c0 commit 2b8532e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

test_collections/matter/sdk_tests/support/python_testing/list_python_tests_classes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,9 @@ def _is_matter_base_test_class(
225225
try:
226226
abs_path = str(candidate.resolve())
227227
if abs_path not in _module_cache:
228-
with open(candidate, "r") as f:
229-
_module_cache[abs_path] = ast.parse(f.read())
228+
_module_cache[abs_path] = ast.parse(
229+
candidate.read_text(encoding="utf-8")
230+
)
230231
imported_module = _module_cache[abs_path]
231232

232233
# Use the absolute path as the cycle-guard key so that

0 commit comments

Comments
 (0)