From b0ab6186ef20ef16d97d9a2f8771417b08ea27f3 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Sun, 20 Feb 2022 21:49:39 +0100 Subject: [PATCH] Ensure that registered Config defaults are serializable to JSON (#5557) --- redbot/core/config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/redbot/core/config.py b/redbot/core/config.py index 6db8af5ba..f1ada22d7 100644 --- a/redbot/core/config.py +++ b/redbot/core/config.py @@ -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)