Update Data.py (#1071)
* Update Data.py Python eval not working with python 3 - bug fix with the exec() part
This commit is contained in:
parent
ddb597a3dd
commit
3f6424cc57
@ -2,6 +2,7 @@
|
|||||||
from ..Node import Node
|
from ..Node import Node
|
||||||
from ...Qt import QtGui, QtCore
|
from ...Qt import QtGui, QtCore
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import sys
|
||||||
from .common import *
|
from .common import *
|
||||||
from ...SRTTransform import SRTTransform
|
from ...SRTTransform import SRTTransform
|
||||||
from ...Point import Point
|
from ...Point import Point
|
||||||
@ -238,7 +239,12 @@ class EvalNode(Node):
|
|||||||
fn = "def fn(**args):\n"
|
fn = "def fn(**args):\n"
|
||||||
run = "\noutput=fn(**args)\n"
|
run = "\noutput=fn(**args)\n"
|
||||||
text = fn + "\n".join([" "+l for l in str(self.text.toPlainText()).split('\n')]) + run
|
text = fn + "\n".join([" "+l for l in str(self.text.toPlainText()).split('\n')]) + run
|
||||||
|
if sys.version_info.major == 2:
|
||||||
exec(text)
|
exec(text)
|
||||||
|
elif sys.version_info.major == 3:
|
||||||
|
ldict = locals()
|
||||||
|
exec(text, globals(), ldict)
|
||||||
|
output = ldict['output']
|
||||||
except:
|
except:
|
||||||
print("Error processing node: %s" % self.name())
|
print("Error processing node: %s" % self.name())
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user