Skip to content

Commit

Permalink
Update execfile/exec logic to support >= python3.9 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfx committed Sep 23, 2021
1 parent eaf8727 commit b9d5291
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions MayaSublime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b9d5291

Please sign in to comment.