When pickling addon state use only builtin types, and add unit test for the pickling and unpickling process.#15556
Conversation
| state[AddonStateCategory.OVERRIDE_COMPATIBILITY].clear() | ||
| self[AddonStateCategory.OVERRIDE_COMPATIBILITY].clear() | ||
| self.manualOverridesAPIVersion = MajorMinorPatch(*addonAPIVersion.BACK_COMPAT_TO) | ||
| self.update(state) |
There was a problem hiding this comment.
is there a reason why using state instead of self was changed and calling update was removed?
The current design was intentional and I believe this change introduces an unnecessary risk to the beta. We have limited time to test upgrading and downgrading NVDA with add-ons as per work in #15439
There was a problem hiding this comment.
There is simply no state local variable anymore. Now the data is loaded into the instance by fromPickledDict, which means that the loading from the dictionary can be tested independently in unit tests. The process is covered by unit tests, which is certainly an improvement to what we had previously. Reading them should give you confidence that functionally the process remained the same.
Opened against beta, to fix regression introduced in 2023.3 development cycle.
Link to issue number:
Fixes #15554
Summary of the issue:
When pickling add-ons state it is necessary to use only builtin types, so that it can be loaded in older versions of NVDA. IN PR #15439 the
backCompatToVersionwas mistakenly pickled as a custom named tupleMajorMinorPatch.This means it is impossible to start older versions of NVDA with the config from the latest beta NVDA crashes on startup.
Description of user facing changes
It should be once again possible to start older versions of NVDA with the config used with the latest beta.
Description of development approach
The
manualOverridesAPIVersionis pickled as a standard tuple. To make sure similar regressions are not introduced I have added unit test covering various scenarios of converting state to, and loading it from, pickled data. Note that I have intentionally not used pickle files, since when the given custom data type is added to NVDA it will always be unpickled successfully.Testing strategy:
Known issues with pull request:
None known
Code Review Checklist: