-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG: Fix crash when pickling dynamic class cycles.
Fixes a bug where we would fail to pickle a class created inside a function if that class participated in a cycle with its own __dict__. Such cycles occur, for example, when a class defines a method that makes a Python 2-style super call, because we have a cycle from class -> __dict__ -> function -> __closure__ -> class. The fix for this is to use the same technique we use to dynamically-created functions: we first pickle an empty "skeleton class", which we memoize before pickling the rest of the class' __dict__. We then invoke a reduce function that re-attaches the class' attributes from the __dict__.
- Loading branch information
Scott Sanderson
committed
Jun 17, 2017
1 parent
c89dc9d
commit 9fa3692
Showing
2 changed files
with
124 additions
and
12 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