From 334ccc35a27c914d4c0347883dbe4bb6375cf56b Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 25 Jan 2023 00:52:37 +0100 Subject: [PATCH] Don't serialize I/O wrappers This removes warnings on `config.get`, where the `logging` configuration key may also contain the current logging stream and we end up with a JSONDecodeError when trying to serialize it. --- platypush/message/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platypush/message/__init__.py b/platypush/message/__init__.py index 7c7a009fd..28879b1a9 100644 --- a/platypush/message/__init__.py +++ b/platypush/message/__init__.py @@ -1,6 +1,7 @@ from abc import ABC, abstractmethod import decimal import datetime +import io import logging import inspect import json @@ -66,6 +67,10 @@ class Message: if isinstance(obj, JSONAble): return obj.to_json() + # Don't serialize I/O wrappers/objects + if isinstance(obj, io.IOBase): + return None + try: return super().default(obj) except Exception as e: