From b9d5291578c69b17735d8c3b0f7b3c18401df714 Mon Sep 17 00:00:00 2001 From: Justin Israel Date: Fri, 24 Sep 2021 06:36:59 +1200 Subject: [PATCH] Update execfile/exec logic to support >= python3.9 (#36) --- MayaSublime.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/MayaSublime.py b/MayaSublime.py index a6a14e7..a5af8af 100644 --- a/MayaSublime.py +++ b/MayaSublime.py @@ -282,9 +282,17 @@ def _sync_settings(): if {ns}: namespace['__file__'] = {fp!r} - {xtype}({cmd!r}, namespace, namespace) else: - {xtype}({cmd!r}, __main__.__dict__, __main__.__dict__) + namespace = __main__.__dict__ + + if {xtype!r} == "exec": + exec({cmd!r}, namespace, namespace) + + else: + with open({fp!r}) as _fp: + _code = compile(_fp.read(), {fp!r}, 'exec') + exec(_code, namespace, namespace) + except: traceback.print_exc() finally: