在上下文中,我正在尝试修补完形填空重叠插件,以便它能在Anki 2.1.28+上工作。这是我尝试的修复方法。本质上,我已尝试将有关刷新卡的部分改编为新API(即,将其放入if else语句+使用add_card钩子在添加时生成id),而在使用note.flush
之前,它始终:
def updateNote(self, fields, full, setopts, custom):
"""Write changes to note"""
note = self.note
options = setopts[1]
for idx, field in enumerate(fields):
name = self.flds["tx"] + str(idx+1)
if name not in note:
print("Missing field. Should never happen.")
continue
note[name] = field if custom else self.processField(field)
if options[3]: # no full clozes
full = ""
else:
full = full if custom else self.processField(full)
note[self.flds["fl"]] = full
note[self.flds["st"]] = createNoteSettings(setopts)
if note.id == 0:
ncol = note.col
note.id = ncol.backend.add_note(note=note.to_backend_note(), deck_id=ncol.conf["curDeck"])
else:
note.flush()
然而,这似乎在Rust后端中产生了一个错误,原因我无法理解:
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, repeat 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 on the add-ons section of our support site.
Debug info:
Anki 2.1.35 (84dcaa86) Python 3.8.0 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=?
Add-ons, last update check: 2020-12-10 23:21:47
Caught exception:
Traceback (most recent call last):
File "aqt\webview.py", line 493, in handler
File "aqt\editor.py", line 483, in <lambda>
File "<C:\Program Files\Anki\decorator.pyc:decorator-gen-110>", line 2, in _addCards
File "anki\hooks.py", line 638, in decorator_wrapper
File "anki\hooks.py", line 635, in repl
File "C:\Users\camin\AppData\Roaming\Anki2\addons21\cloze_overlapper\editor.py", line 308, in onAddCards
oldret = _old(self)
File "aqt\addcards.py", line 191, in _addCards
File "<C:\Program Files\Anki\decorator.pyc:decorator-gen-108>", line 2, in addNote
File "anki\hooks.py", line 638, in decorator_wrapper
File "anki\hooks.py", line 635, in repl
File "C:\Users\camin\AppData\Roaming\Anki2\addons21\cloze_overlapper\editor.py", line 343, in onAddNote
note = _old(addcards, note)
File "aqt\addcards.py", line 178, in addNote
File "anki\collection.py", line 345, in add_note
File "anki\rsbackend_gen.py", line 339, in add_note
File "anki\rsbackend.py", line 262, in _run_command
pyo3_runtime.PanicException: assertion failed: note.id.0 == 0
Caught exception:
Traceback (most recent call last):
File "aqt\webview.py", line 493, in handler
File "C:\Users\camin\AppData\Roaming\Anki2\addons21\516643804\main.py", line 93, in oncallback
self.checkValid()
File "aqt\editor.py", line 487, in checkValid
File "anki\notes.py", line 150, in dupeOrEmpty
File "anki\rsbackend_gen.py", line 404, in note_is_duplicate_or_empty
File "anki\rsbackend.py", line 262, in _run_command
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"
这是怎么回事?我所做的更改如何导致后端出现问题
目前没有回答
相关问题 更多 >
编程相关推荐