glutanimate / reset-card-scheduling

Fork of baitisj/anki-reset-card-scheduling with some added features and support for Anki 2.1
https://ankiweb.net/shared/info/300884351
GNU Affero General Public License v3.0
11 stars 2 forks source link

Error with Anki v23.10 (incl. fix/workaround) #3

Open Heart1010 opened 1 year ago

Heart1010 commented 1 year ago

After the v23.10 update the add-on doesn't work anymore.

Anki 23.10 (51a10f09) Python 3.9.15 Qt 6.5.3 PyQt 6.5.3
Platform: Windows-10-10.0.19045
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2023-11-07 10:11:33

When loading Reset Card Scheduling:
Traceback (most recent call last):
  File "aqt.addons", line 244, in loadAddons
  File "C:\Users\username\AppData\Roaming\Anki2\addons21\300884351\__init__.py", line 15, in <module>
    from . import main
  File "C:\Users\username\AppData\Roaming\Anki2\addons21\300884351\main.py", line 21, in <module>
    from .consts import anki21
  File "C:\Users\username\AppData\Roaming\Anki2\addons21\300884351\consts.py", line 22, in <module>
    addon_path = os.path.dirname(__file__).decode(sys_encoding)
AttributeError: 'str' object has no attribute 'decode'

A user mentioned in a review to change the following line

https://github.com/glutanimate/reset-card-scheduling/blob/6f62657ebe1b0683818bff7d55797fdebb3c716d/src/reset_card_scheduling/consts.py#L22

to

image https://ankiweb.net/shared/info/300884351

In Python 2, string objects expose a decode() function. In Python 3, however, you don't have to decode your strings they're stored in Unicode.

The new way to check versions - see https://forums.ankiweb.net/t/porting-tips-for-anki-23-10/35916

image

cmwfuchs commented 10 months ago

As changing line 22 results in an if-statement with two equal outcomes, I took the liberty of rewriting the consts.py and opening a pull request.