Pin text I/O to UTF-8 and fail CI on locale-dependent reads/writes (#3296)
Co-authored-by: ShuQingDollarVoyager <57471784+ShuQingDollarVoyager@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
52ad0a8876
commit
5285e936a9
2 changed files with 76 additions and 57 deletions
|
|
@ -92,7 +92,7 @@ def update_claude_config(
|
|||
config_file = config_dir / "claude_desktop_config.json"
|
||||
if not config_file.exists(): # pragma: lax no cover
|
||||
try:
|
||||
config_file.write_text("{}")
|
||||
config_file.write_text("{}", encoding="utf-8")
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Failed to create Claude config file",
|
||||
|
|
@ -103,7 +103,7 @@ def update_claude_config(
|
|||
return False
|
||||
|
||||
try:
|
||||
config = json.loads(config_file.read_text())
|
||||
config = json.loads(config_file.read_bytes())
|
||||
if "mcpServers" not in config:
|
||||
config["mcpServers"] = {}
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ def update_claude_config(
|
|||
|
||||
config["mcpServers"][server_name] = server_config
|
||||
|
||||
config_file.write_text(json.dumps(config, indent=2))
|
||||
config_file.write_text(json.dumps(config, indent=2), encoding="utf-8")
|
||||
logger.info(
|
||||
f"Added server '{server_name}' to Claude config",
|
||||
extra={"config_file": str(config_file)},
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ The canonical safe pattern::
|
|||
|
||||
@mcp.resource("file://docs/{+path}")
|
||||
def read_doc(path: str) -> str:
|
||||
return safe_join("/data/docs", path).read_text()
|
||||
return safe_join("/data/docs", path).read_text(encoding="utf-8")
|
||||
"""
|
||||
|
||||
import string
|
||||
|
|
|
|||
Loading…
Reference in a new issue