Gustaf-C / anki-chinese-support-3

Anki add-on providing support for Chinese study
https://ankiweb.net/shared/info/1752008591
GNU General Public License v3.0
26 stars 7 forks source link

Error when autofilling #1

Closed Gustaf-C closed 9 months ago

Gustaf-C commented 9 months ago

Started happen suddenly, can't autofill anymore.

To reproduce:

  1. Add card
  2. Write hanzi
  3. Press tab
Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue to the add-on author.
Debug info:
Anki 23.10 (dfe0370a) Python 3.9.7 Qt 6.5.3 PyQt 6.5.3
Platform: macOS-11.7.10-x86_64-i386-64bit
Flags: frz=False ao=True sv=3
Add-ons, last update check: 2023-10-19 13:04:48
Add-ons possibly involved: ⁨chinese⁩

Caught exception:
Traceback (most recent call last):
  File "Kod/anki/qt/aqt/webview.py", line 46, in cmd
    return json.dumps(self.onCmd(str))
  File "Kod/anki/qt/aqt/webview.py", line 153, in _onCmd
    return self._onBridgeCmd(str)
  File "Kod/anki/qt/aqt/webview.py", line 666, in _onBridgeCmd
    return self.onBridgeCmd(cmd)
  File "/Kod/anki/qt/aqt/editor.py", line 418, in onBridgeCmd
    if gui_hooks.editor_did_unfocus_field(False, self.note, ord):
  File "Kod/anki/out/qt/_aqt/hooks.py", line 2548, in __call__
    changed = anki.hooks.runFilter(
  File "Kod/anki/pylib/anki/hooks.py", line 45, in runFilter
    arg = func(arg, *args)
  File "Library/Application Support/Anki2/addons21/chinese/edit.py", line 74, in onFocusLost
    if update_fields(note, field, allFields):
  File "Library/Application Support/Anki2/addons21/chinese/behavior.py", line 311, in update_fields
    fill_all_defs(hanzi, copy)
  File "Library/Application Support/Anki2/addons21/chinese/behavior.py", line 96, in fill_all_defs
    fill_def(hanzi, note, lang='en'),
  File "Library/Application Support/Anki2/addons21/chinese/behavior.py", line 84, in fill_def
    definition = translate(hanzi, lang)
  File "Library/Application Support/Anki2/addons21/chinese/translate.py", line 61, in translate
    return translate_local(hanzi, lang)
  File "Library/Application Support/Anki2/addons21/chinese/translate.py", line 52, in translate_local
    return colorize_dict(res.replace('\n', '\n<br>'))
  File "/Library/Application Support/Anki2/addons21/chinese/color.py", line 104, in colorize_dict
    return sub(r'([\%s|]+)\[(.*?)\]' % HANZI_RANGE, _sub, text)
  File "Kod/anki/out/extracted/python/lib/python3.9/re.py", line 210, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "Library/Application Support/Anki2/addons21/chinese/color.py", line 100, in _sub
    s += colorize_fuse(split_hanzi(hanzi, grouped=False), pinyin, True)
  File "Library/Application Support/Anki2/addons21/chinese/hanzi.py", line 61, in split_hanzi
    separated = list(cut(hanzi))
  File "Library/Application Support/Anki2/addons21/chinese/lib/jieba/__init__.py", line 308, in cut
    for word in cut_block(blk):
  File "Library/Application Support/Anki2/addons21/chinese/lib/jieba/__init__.py", line 240, in __cut_DAG
    DAG = self.get_DAG(sentence)
  File "Library/Application Support/Anki2/addons21/chinese/lib/jieba/__init__.py", line 186, in get_DAG
    self.check_initialized()
  File "Library/Application Support/Anki2/addons21/chinese/lib/jieba/__init__.py", line 175, in check_initialized
    self.initialize()
  File "/Library/Application Support/Anki2/addons21/chinese/lib/jieba/__init__.py", line 150, in initialize
    self.FREQ, self.total = self.gen_pfdict(self.get_dict_file())
  File "Library/Application Support/Anki2/addons21/chinese/lib/jieba/__init__.py", line 359, in get_dict_file
    return get_module_res(DEFAULT_DICT_NAME)
  File "Library/Application Support/Anki2/addons21/chinese/lib/jieba/_compat.py", line 7, in <lambda>
    get_module_res = lambda *res: importlib.resources.resource_stream(__name__,
AttributeError: module 'importlib.resources' has no attribute 'resource_stream'
Gustaf-C commented 9 months ago

Might be fixed after reverting changes to /chinese/lib/jieba/_compat.py

Gustaf-C commented 9 months ago

Seems to be solved after revert