Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed AttribiteError when unpickling; Optimized pickling
Details: * When unpickling an object of NocaseList, an AttributeError is raised in extend(), stating that _lc_list is missing. Adding debug prints reveals that pickle.load() calls extend() on a NocaseList object that has not been initialized with __init__(). This change mitigates that by handling the exception in extend() and setting _lc_list freshly. * This change also adds __setstate__() and __getstate__() methods that optimize the serialized data by only having the original list serialized. For unknown reasons, pickle does not call __setstate__() on Python 2 for the NocaseList class. Therefore, the __getstate__() and __setstate__() methods are deleted when running on Python 2, unless the documentation is built. Signed-off-by: Andreas Maier <andreas.r.maier@gmx.de>
- Loading branch information
1 parent
581b3af
commit be8d83a
Showing
4 changed files
with
122 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters