From 77fc7453500c427a2f5d0a723d6106df3625b7e5 Mon Sep 17 00:00:00 2001 From: James O'Beirne Date: Sun, 16 Jan 2022 09:30:46 -0500 Subject: [PATCH] enable SimpleNamespace for unpickling --- mitogen/core.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mitogen/core.py b/mitogen/core.py index bee722e63..152f456ef 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -151,12 +151,14 @@ FsPathTypes = (str,) BufferType = lambda buf, start: memoryview(buf)[start:] long = int + from types import SimpleNamespace else: b = str BytesType = str FsPathTypes = (str, unicode) BufferType = buffer UnicodeType = unicode + SimpleNamespace = None AnyTextType = (BytesType, UnicodeType) @@ -864,6 +866,8 @@ def _find_global(self, module, func): return self._unpickle_bytes elif module == '__builtin__' and func == 'bytes': return BytesType + elif SimpleNamespace and module == 'types' and func == 'SimpleNamespace': + return SimpleNamespace raise StreamError('cannot unpickle %r/%r', module, func) @property @@ -3132,7 +3136,7 @@ def stream_by_id(self, dst_id): This can be used from any thread, but its output is only meaningful from the context of the :class:`Broker` thread, as disconnection or replacement could happen in parallel on the broker thread at any - moment. + moment. """ return ( self._stream_by_id.get(dst_id) or