events: sanitize generator for json safety

closes #3903

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-10-31 20:30:00 +01:00
parent 97b5ea2365
commit cd0d898a4b
1 changed files with 3 additions and 0 deletions

View File

@ -2,6 +2,7 @@
import re
from dataclasses import asdict, is_dataclass
from pathlib import Path
from types import GeneratorType
from typing import Any, Optional
from uuid import UUID
@ -93,6 +94,8 @@ def sanitize_item(value: Any) -> Any:
value = asdict(value)
if isinstance(value, dict):
return sanitize_dict(value)
if isinstance(value, GeneratorType):
return sanitize_item(list(value))
if isinstance(value, list):
new_values = []
for item in value: