From 77e4c3c40185e13de57b70b81364bd4f8426c201 Mon Sep 17 00:00:00 2001 From: Justin Israel Date: Sun, 26 Sep 2021 09:57:53 +1300 Subject: [PATCH 1/3] Fix StringIO import for py3 --- MayaSublime.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MayaSublime.py b/MayaSublime.py index a5af8af..71e02cc 100644 --- a/MayaSublime.py +++ b/MayaSublime.py @@ -309,9 +309,12 @@ def _sync_settings(): import maya.OpenMaya try: - from cStringIO import StringIO + from io import StringIO except ImportError: - from StringIO import StringIO + try: + from cStringIO import StringIO + except ImportError: + from StringIO import StringIO if '_MayaSublime_ScriptEditorOutput_CID' not in globals(): _MayaSublime_ScriptEditorOutput_CID = None From e54cb230cbbd5272cea1b488825a134a4ae66b1f Mon Sep 17 00:00:00 2001 From: Justin Israel Date: Sun, 26 Sep 2021 09:58:25 +1300 Subject: [PATCH 2/3] 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 From ad515e98ec41a600aef2075b7e30f35d75eee0e6 Mon Sep 17 00:00:00 2001 From: Justin Israel Date: Mon, 27 Sep 2021 09:01:27 +1300 Subject: [PATCH 3/3] Open source files with utf-8 (#38) --- MayaSublime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MayaSublime.py b/MayaSublime.py index 5e8cae4..871a3c4 100644 --- a/MayaSublime.py +++ b/MayaSublime.py @@ -289,7 +289,7 @@ def _sync_settings(): exec({cmd!r}, namespace, namespace) else: - with open({fp!r}, 'rb') as _fp: + with open({fp!r}, encoding='utf-8') as _fp: _code = compile(_fp.read(), {fp!r}, 'exec') exec(_code, namespace, namespace)