Ensure that registered Config defaults are serializable to JSON (#5557)

This commit is contained in:
jack1142 2022-02-20 21:49:39 +01:00 committed by GitHub
parent 9baf9ba546
commit b0ab6186ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
import asyncio
import collections.abc
import json
import logging
import pickle
import weakref
@ -807,7 +808,8 @@ class Config(metaclass=ConfigMeta):
if key not in self._defaults:
self._defaults[key] = {}
data = pickle.loads(pickle.dumps(kwargs, -1))
# this serves as a 'deep copy' and verification that the default is serializable to JSON
data = json.loads(json.dumps(kwargs))
for k, v in data.items():
to_add = self._get_defaults_dict(k, v)