Skip to content

Commit 75b3933

Browse files
sahiixxCopilot
andauthored
Update tools/search_templates.py
Co-authored-by: Copilot <[email protected]>
1 parent 5616b50 commit 75b3933

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/search_templates.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ def iter_json_files(root_dir: str) -> Iterable[str]:
4747

4848
def safe_read_text(path: str) -> str:
4949
try:
50-
with open(path, 'r', encoding='utf-8', errors='ignore') as f:
50+
with open(path, 'r', encoding='utf-8', errors='replace') as f:
5151
return f.read()
52-
except Exception:
52+
except (OSError, UnicodeDecodeError):
5353
return ''
5454

5555

5656
def try_parse_json(path: str) -> Optional[dict]:
5757
try:
58-
with open(path, 'r', encoding='utf-8', errors='ignore') as f:
58+
with open(path, 'r', encoding='utf-8', errors='replace') as f:
5959
return json.load(f)
60-
except Exception:
60+
except (OSError, UnicodeDecodeError, json.JSONDecodeError):
6161
return None
6262

6363

0 commit comments

Comments
 (0)