Skip to content

Commit

Permalink
Merge branch '38_py3_encoding'
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfx committed Sep 26, 2021
2 parents 9379791 + ad515e9 commit 731437d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions MayaSublime.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def _sync_settings():
exec({cmd!r}, namespace, namespace)
else:
with open({fp!r}) as _fp:
with open({fp!r}, encoding='utf-8') as _fp:
_code = compile(_fp.read(), {fp!r}, 'exec')
exec(_code, namespace, namespace)
Expand All @@ -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
Expand Down Expand Up @@ -386,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
Expand Down

1 comment on commit 731437d

@JokerMartini
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should change this to support forward and backwards compatibility. The code below fixes the issues i reported....

else:
	try:
		with open({fp!r}) as _fp:
			_code = compile(_fp.read(), {fp!r}, 'exec')
			exec(_code, namespace, namespace)
	except:
		with open({fp!r}, encoding='utf-8') as _fp:
			_code = compile(_fp.read(), {fp!r}, 'exec')
			exec(_code, namespace, namespace)

Please sign in to comment.