Fix old style exception raise and exec syntax
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 03 Oct 2018 11:44:57 +0300
changeset 2419 c081dabc0f63
parent 2418 5587c490a070
child 2420 290b77b72123
Fix old style exception raise and exec syntax
runtime/PLCObject.py
tests/tools/test_application.py
--- a/runtime/PLCObject.py	Tue Oct 02 18:08:49 2018 +0300
+++ b/runtime/PLCObject.py	Wed Oct 03 11:44:57 2018 +0300
@@ -32,6 +32,7 @@
 from time import time
 import _ctypes  # pylint: disable=wrong-import-order
 import Pyro.core as pyro
+import six
 
 from runtime.typemapping import TypeTranslator
 from runtime.loglevels import LogLevelsDefault, LogLevelsCount
@@ -147,7 +148,10 @@
         if _job.success:
             return _job.result
         else:
-            raise _job.exc_info[0], _job.exc_info[1], _job.exc_info[2]
+            exc_type = _job.exc_info[0]
+            exc_value = _job.exc_info[1]
+            exc_traceback = _job.exc_info[2]
+            six.reraise(exc_type, exc_value, exc_traceback)
 
     def quit(self):
         """
@@ -697,7 +701,7 @@
 
     def RemoteExec(self, script, *kwargs):
         try:
-            exec script in kwargs
+            exec(script, kwargs)
         except Exception:
             _e_type, e_value, e_traceback = sys.exc_info()
             line_no = traceback.tb_lineno(get_last_traceback(e_traceback))
--- a/tests/tools/test_application.py	Tue Oct 02 18:08:49 2018 +0300
+++ b/tests/tools/test_application.py	Wed Oct 03 11:44:57 2018 +0300
@@ -30,6 +30,7 @@
 import unittest
 import time
 
+import six
 import pytest
 import wx
 import ddt
@@ -71,7 +72,10 @@
     def CheckForErrors(self):
         if self.exc_info is not None:
             # reraise catched previously exception
-            raise self.exc_info[0], self.exc_info[1], self.exc_info[2]
+            exc_type = self.exc_info[0]
+            exc_value = self.exc_info[1]
+            exc_traceback = self.exc_info[2]
+            six.reraise(exc_type, exc_value, exc_traceback)
 
     def ProcessEvents(self):
         for dummy in range(0, 30):