mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Core: store multidata/multisave enums by value on py3.11 (#1783)
This is what py3.10 did and should be better for AP than the new default
This commit is contained in:
9
Utils.py
9
Utils.py
@@ -508,6 +508,15 @@ def restricted_loads(s):
|
||||
return RestrictedUnpickler(io.BytesIO(s)).load()
|
||||
|
||||
|
||||
class ByValue:
|
||||
"""
|
||||
Mixin for enums to pickle value instead of name (restores pre-3.11 behavior). Use as left-most parent.
|
||||
See https://github.com/python/cpython/pull/26658 for why this exists.
|
||||
"""
|
||||
def __reduce_ex__(self, prot):
|
||||
return self.__class__, (self._value_, )
|
||||
|
||||
|
||||
class KeyedDefaultDict(collections.defaultdict):
|
||||
"""defaultdict variant that uses the missing key as argument to default_factory"""
|
||||
default_factory: typing.Callable[[typing.Any], typing.Any]
|
||||
|
||||
Reference in New Issue
Block a user