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:
patricev 2020-05-30 08:38:03 +02:00 committed by GitHub
parent ddb597a3dd
commit 3f6424cc57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
exec(text) if sys.version_info.major == 2:
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