← Back to team overview

edubuntu-bugs team mailing list archive

[Bug 2004098] Re: [SRU] python 3.10 does stricter type checking

 

** Description changed:

+ [ Impact ]
+ 
+ Users will fail to open the preferences window to set their preferences.
+ Or click on the gearwheel icon of a deck and choose options.
+ 
+ 
+ Trying to open the preferences will show the below error:
+ 
+ Caught exception:
+   File "/usr/share/anki/aqt/main.py", line 882, in onPrefs
+     aqt.dialogs.open("Preferences", self)
+   File "/usr/share/anki/aqt/__init__.py", line 82, in open
+     instance = creator(*args)
+   File "/usr/share/anki/aqt/preferences.py", line 25, in __init__
+     self.setupCollection()
+   File "/usr/share/anki/aqt/preferences.py", line 80, in setupCollection
+     f.lrnCutoff.setValue(qc['collapseTime']/60.0)
+ <class 'TypeError'>: setValue(self, int): argument 1 has unexpected type 'float'
+ 
+ Trying to open the options will show the following error:
+ 
+ Caught exception:
+   File "/usr/share/anki/aqt/deckbrowser.py", line 213, in <lambda>
+     a.triggered.connect(lambda b, did=did: self._options(did))
+   File "/usr/share/anki/aqt/deckbrowser.py", line 242, in _options
+     self.mw.onDeckConf()
+   File "/usr/share/anki/aqt/main.py", line 869, in onDeckConf
+     aqt.deckconf.DeckConf(self, deck)
+   File "/usr/share/anki/aqt/deckconf.py", line 25, in __init__
+     self.setupConfs()
+   File "/usr/share/anki/aqt/deckconf.py", line 49, in setupConfs
+     self.loadConfs()
+   File "/usr/share/anki/aqt/deckconf.py", line 66, in loadConfs
+     self.onConfChange(startOn)
+   File "/usr/share/anki/aqt/deckconf.py", line 89, in onConfChange
+     self.loadConf()
+   File "/usr/share/anki/aqt/deckconf.py", line 175, in loadConf
+     f.lrnFactor.setValue(c['initialFactor']/10.0)
+ <class 'TypeError'>: setValue(self, int): argument 1 has unexpected type 'float'
+ 
+ [ Test Plan ]
+ 
+ Combines testplan for #2015698 and this one.
+ 
+ install anki.
+ start anki
+ Click on Tools -> Preferences
+ 
+ If the package is not fixed the Prefenrences window will show the above
+ error.
+ 
+ With the fixed package, we can open the Preferences window after anki
+ has started.
+ 
+ Just to test anki still works:
+ 1. Click on "Create Deck" and create a deck
+ 2. (extra step compared to #2015698) - Click on the gearwheel icon of a deck and choose options and confirm the Options windows is displayed properly.
+ 3. Create a file in any folder with the content "what am I doing?;Testing SRU" or any content you want with text separated by semicolons.
+ 4. Click on File -> Import and select the text file created in above step.
+ 5. Click on the Deck name, and then click on "Study Now".
+ 6. It should show the question "what am I doing?"
+ 7. Click on "Show Answer", and it will show "Testing SRU".
+ 
+ [ Where problems could occur ]
+ 
+ int does not round but truncates towards zero. There is a possibility
+ that the program was written with the assumption that non-int values
+ would be rounded to the nearest integer.
+ 
+ The typecast to int might cause some change in the time limit if the
+ user tries to change that value in the preferences or in the option.
+ Some of the values being divided may become 0 due to the typecast. So,
+ users who are changing these values may find the chaging the values is
+ not producing the desired changes.
+ 
+ [ Other Info ]
+ 
+ The problem is because of the strict type checking in Python 3.10 and was fixed in Mantic.
+ The original fix from this bug report missed one issue which has been reported in #2015698.
+ 
+ I have added the change of #2015698 in this same patch instead of
+ creating a new patch.
+ 
+ [ Original Bug Description ]
+ 
+ 
  [Impact]
  
  python 3.10 does stricter type checking and hence anki fails in some
  cases, for example it is no longer possible to access the preferences of
  a deck.
  
  [steps to reproduce]
  - install and start anki
  - choose a deck and click on the gearwheel icon to choose options
  - anki crashes with a type error
  
  [regression potential]
  
  Currently, the program crashes for the code-paths in question.  The
  receiving functions expect to be handed an int and casting the
  parameters of the function calls to int ensures the correct type.
  
  int does not round but truncates towards zero.  There is a possibility
  that the program was written with the assumption that non-int values
  would be rounded to the nearest integer.  It is my understanding that
  lrnFactor, easyBonus, lapMult and lrnCutoff are numbers to determine how
  soon flash cards will be shown again for learning.  The impact from any
  "bug" in determining this should be fairly insignificant.
  
  Code inspection was only cursory, though.
  
  [further information]
  
  https://forums.ankiweb.net/t/selecting-options-or-preferences-throws-an-error/24509
  https://forums.ankiweb.net/t/cant-open-settings/16644
  https://www.reddit.com/r/Anki/comments/wvuc3w/trying_to_go_into_preferences_and_it_gives_me_this/
  
  I have provided a bug-fixed package for jammy in my stable PPA, the
  package should be usable in later releases, too.

-- 
You received this bug notification because you are a member of Edubuntu
Bugsquad, which is subscribed to anki in Ubuntu.
https://bugs.launchpad.net/bugs/2004098

Title:
  [SRU] python 3.10 does stricter type checking

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/anki/+bug/2004098/+subscriptions



References