registry.Json: Fix serialization/deserialization points

self.value should be the deserialized value (because we set
'self.value = default' in registry.close()), so
setValue()/__call__() should return it as-is.

Doing otherwise failed serialization of the default, and crashed
with the same error as in https://github.com/progval/Limnoria/issues/1604
since 8ec873015aac3ba4193a2d498eb294975615b296
This commit is contained in:
Valentin Lorentz 2025-04-06 09:00:23 +02:00
parent ccf26351f5
commit c795cdc655

View File

@ -920,13 +920,11 @@ class TemplatedString(String):
class Json(String):
__slots__ = ()
# Json-serializable data
def set(self, v):
self.setValue(json.loads(v))
def setValue(self, v):
super(Json, self).setValue(json.dumps(v))
def __call__(self):
return json.loads(super(Json, self).__call__())
def __str__(self):
return json.dumps(self())
class _Context:
def __init__(self, var):