From 5f4dc0d555b4776216f4c30b0450f4dd5e862142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AF=BB=E9=9A=90=E8=80=85?= Date: Thu, 27 Feb 2025 16:48:30 +0800 Subject: [PATCH 1/3] fix #13392, jieba 'PosixPath' object is not iterable make sure jieba.load_userdict() have a string parameter --- CHANGES.rst | 2 ++ sphinx/search/zh.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index c257b3b11b1..856612bbff4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,5 +16,7 @@ Features added Bugs fixed ---------- +* #13392: HTML Search: make sure the parameter that passed to jieba.load_userdict() is string_types + Testing ------- diff --git a/sphinx/search/zh.py b/sphinx/search/zh.py index a63b6d63aa0..9f5a6d23a81 100644 --- a/sphinx/search/zh.py +++ b/sphinx/search/zh.py @@ -232,7 +232,7 @@ def __init__(self, options: dict[str, str]) -> None: def init(self, options: dict[str, str]) -> None: if JIEBA: - dict_path = options.get('dict', JIEBA_DEFAULT_DICT) + dict_path = options.get('dict', JIEBA_DEFAULT_DICT.as_posix()) if dict_path and Path(dict_path).is_file(): jieba.load_userdict(dict_path) From fda96cd769fd748ed5c7e289d7f0f513224c2d61 Mon Sep 17 00:00:00 2001 From: xunyinzhe <83520838+xunyinzhe@users.noreply.github.com> Date: Thu, 27 Feb 2025 17:21:29 +0800 Subject: [PATCH 2/3] Update CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 856612bbff4..dea4fcf3445 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,7 +16,7 @@ Features added Bugs fixed ---------- -* #13392: HTML Search: make sure the parameter that passed to jieba.load_userdict() is string_types +* #13392: HTML Search: make sure jieba.load_userdict got a string param. Testing ------- From 36c7c60b780b3f6796143f4effd9e0bb0b973bf3 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sat, 1 Mar 2025 20:33:37 +0000 Subject: [PATCH 3/3] Update --- CHANGES.rst | 2 +- sphinx/search/zh.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index dea4fcf3445..99e1c9bf89f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,7 +16,7 @@ Features added Bugs fixed ---------- -* #13392: HTML Search: make sure jieba.load_userdict got a string param. +* #13392: Fix argument type for ``jieba.load_userdict()``. Testing ------- diff --git a/sphinx/search/zh.py b/sphinx/search/zh.py index 9f5a6d23a81..4eb94bf599b 100644 --- a/sphinx/search/zh.py +++ b/sphinx/search/zh.py @@ -232,9 +232,9 @@ def __init__(self, options: dict[str, str]) -> None: def init(self, options: dict[str, str]) -> None: if JIEBA: - dict_path = options.get('dict', JIEBA_DEFAULT_DICT.as_posix()) + dict_path = options.get('dict', JIEBA_DEFAULT_DICT) if dict_path and Path(dict_path).is_file(): - jieba.load_userdict(dict_path) + jieba.load_userdict(str(dict_path)) self.stemmer = snowballstemmer.stemmer('english')