From 11d49fd4762c259b20b86d80a1a0c7b047f0ac54 Mon Sep 17 00:00:00 2001 From: profitroll Date: Sun, 6 Aug 2023 01:25:08 +0200 Subject: [PATCH] Fixed escape_forward_slashes error --- libbot/__main__.py | 2 ++ libbot/sync/__init__.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libbot/__main__.py b/libbot/__main__.py index a801c9d..cf8adb4 100644 --- a/libbot/__main__.py +++ b/libbot/__main__.py @@ -35,6 +35,8 @@ async def json_write(data: Any, path: Union[str, Path]) -> None: async with aiofiles.open(str(path), mode="w", encoding="utf-8") as f: await f.write( dumps(data, ensure_ascii=False, escape_forward_slashes=False, indent=4) + if hasattr(dumps, "escape_forward_slashes") + else dumps(data, ensure_ascii=False, indent=4) ) diff --git a/libbot/sync/__init__.py b/libbot/sync/__init__.py index 6667519..2553dce 100644 --- a/libbot/sync/__init__.py +++ b/libbot/sync/__init__.py @@ -29,7 +29,11 @@ def json_write(data: Any, path: Union[str, Path]) -> None: * path (`Union[str, Path]`): Path-like object or path as a string of a destination """ with open(str(path), mode="w", encoding="utf-8") as f: - f.write(dumps(data, ensure_ascii=False, escape_forward_slashes=False, indent=4)) + f.write( + dumps(data, ensure_ascii=False, escape_forward_slashes=False, indent=4) + if hasattr(dumps, "escape_forward_slashes") + else dumps(data, ensure_ascii=False, indent=4) + ) def nested_set(target: dict, value: Any, *path: str, create_missing=True) -> dict: