Skip to content

Commit

Permalink
enable SimpleNamespace for unpickling
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesob committed Aug 11, 2022
1 parent 5b505f5 commit 8b88cb4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mitogen/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -850,6 +852,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
Expand Down Expand Up @@ -3102,7 +3106,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
Expand Down

0 comments on commit 8b88cb4

Please sign in to comment.