From e54cb230cbbd5272cea1b488825a134a4ae66b1f Mon Sep 17 00:00:00 2001 From: Justin Israel Date: Sun, 26 Sep 2021 09:58:25 +1300 Subject: [PATCH] Fix byte/str handling when reading source file and sending to socket (#38) --- MayaSublime.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MayaSublime.py b/MayaSublime.py index 71e02cc..5e8cae4 100644 --- a/MayaSublime.py +++ b/MayaSublime.py @@ -289,7 +289,7 @@ def _sync_settings(): exec({cmd!r}, namespace, namespace) else: - with open({fp!r}) as _fp: + with open({fp!r}, 'rb') as _fp: _code = compile(_fp.read(), {fp!r}, 'exec') exec(_code, namespace, namespace) @@ -389,13 +389,15 @@ def _streamToMayaSublime(msg, msgType, *args): return try: - _MayaSublime_SOCK.sendto(part, (host, port)) + _MayaSublime_SOCK.sendto(_py_str(part), (host, port)) except Exception as e: if e.errno == errno.EMSGSIZE: # We have hit a message size limit. # Scale down and try the packet again bufsize /= 2 + if bufsize < 1: + raise buf.seek(pos) continue # Some other error