Skip to content

Commit

Permalink
Fix: exec in is not python3 compatible, use dicts as args instead
Browse files Browse the repository at this point in the history
  • Loading branch information
zack-vii authored and tfredian committed Nov 3, 2018
1 parent d947b4c commit 9ab314c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mdsobjects/python/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3266,7 +3266,7 @@ def getImportString(cls):
try:
import_string = "from %s import %s" % (cls.__module__.split('.',1)[0],cls.__name__)
# test if this would work
exec(compile(import_string,'<string>','exec')) in {},{}
exec(compile(import_string,'<string>','exec'),{},{})
return import_string
except ImportError:
try:
Expand Down
2 changes: 1 addition & 1 deletion tdi/python/Py.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def Py(cmds, *arg):
cmds="\n".join(cmdlist)
env = {"arg":arg,'MDSplus':MDSplus}
try:
exec(compile(cmds,'<string>','exec'),globals(),env)
exec(compile(cmds,'<string>','exec'),env,env)
except Exception as exc:
_tb.print_exc()
MDSplus.String(exc).setTdiVar("_py_exception")
Expand Down
2 changes: 1 addition & 1 deletion tdi/python/addfun.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def addfun(name,code):
sys.modules[modulename] = types.ModuleType(modulename)
code = MDSplus.Data.data(code)
env = {}
exec(code) in env
exec(compile(code,"TDI/%s"%(name,),'exec'),env,env)
sys.modules[modulename].__dict__[mdsname] = env[name]
mdsname = MDSplus.String(mdsname)
return MDSplus.EQUALS(MDSplus.PUBLIC(mdsname),mdsname).evaluate()
Expand Down

0 comments on commit 9ab314c

Please sign in to comment.