events: sanitize generator for json safety
closes #3903 Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
97b5ea2365
commit
cd0d898a4b
|
@ -2,6 +2,7 @@
|
||||||
import re
|
import re
|
||||||
from dataclasses import asdict, is_dataclass
|
from dataclasses import asdict, is_dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from types import GeneratorType
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
|
@ -93,6 +94,8 @@ def sanitize_item(value: Any) -> Any:
|
||||||
value = asdict(value)
|
value = asdict(value)
|
||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
return sanitize_dict(value)
|
return sanitize_dict(value)
|
||||||
|
if isinstance(value, GeneratorType):
|
||||||
|
return sanitize_item(list(value))
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
new_values = []
|
new_values = []
|
||||||
for item in value:
|
for item in value:
|
||||||
|
|
Reference in New Issue