Repository: qpid-proton
Updated Branches:
  refs/heads/master f62369d92 -> 7ea2ee12a


PROTON-1265: Fix some problems using python 3 with proton-c


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/7ea2ee12
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/7ea2ee12
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/7ea2ee12

Branch: refs/heads/master
Commit: 7ea2ee12afb983a8c3a9b7fedd2eb974d763b1c8
Parents: f62369d
Author: Andrew Stitcher <[email protected]>
Authored: Wed Jul 20 02:21:12 2016 -0400
Committer: Andrew Stitcher <[email protected]>
Committed: Wed Jul 20 17:46:35 2016 -0400

----------------------------------------------------------------------
 examples/cpp/example_test.py        | 18 +++++++++---------
 tests/python/proton_tests/common.py | 27 +++++++++++++--------------
 2 files changed, 22 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7ea2ee12/examples/cpp/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/example_test.py b/examples/cpp/example_test.py
index bb7c48d..32d884e 100644
--- a/examples/cpp/example_test.py
+++ b/examples/cpp/example_test.py
@@ -64,8 +64,9 @@ class Proc(Popen):
         if not skip_valgrind:
             args = self.env_args + args
         try:
-            Popen.__init__(self, args, stdout=PIPE, stderr=STDOUT, **kwargs)
-        except Exception, e:
+            Popen.__init__(self, args, stdout=PIPE, stderr=STDOUT,
+                           universal_newlines=True,  **kwargs)
+        except Exception as e:
             raise ProcError(self, str(e))
         # Start reader thread.
         self.pattern = ready
@@ -84,16 +85,17 @@ class Proc(Popen):
             while True:
                 l = self.stdout.readline()
                 if not l: break
-                self.out += l.translate(None, "\r")
+                self.out += l
                 if self.pattern is not None:
                     if re.search(self.pattern, l):
                         self.ready_set = True
                         self.ready.set()
             if self.wait() != 0:
                 raise ProcError(self)
-        except Exception, e:
-            self.error = sys.exc_info()
+        except Exception as e:
+            self.error = e
         finally:
+            self.stdout.close()
             self.ready_set = True
             self.ready.set()
 
@@ -107,9 +109,7 @@ class Proc(Popen):
 
     def check_(self):
         if self.error:
-            if isinstance(self.error, Exception):
-                raise self.error
-            raise self.error[0], self.error[1], self.error[2] # with traceback
+            raise self.error
 
     def wait_ready(self):
         """Wait for ready to appear in output"""
@@ -145,7 +145,7 @@ else:
                 type(self)._setup_class_count = len(
                     inspect.getmembers(
                         type(self),
-                        predicate=lambda(m): inspect.ismethod(m) and 
m.__name__.startswith('test_')))
+                        predicate=lambda m: inspect.ismethod(m) and 
m.__name__.startswith('test_')))
                 type(self).setUpClass()
 
         def tearDown(self):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7ea2ee12/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py 
b/tests/python/proton_tests/common.py
index eee87c2..9cc0ba2 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -272,7 +272,7 @@ class MessengerApp(object):
         """Find filename in the searchpath
             return absolute path to the file or None
         """
-        paths = string.split(searchpath, os.pathsep)
+        paths = searchpath.split(os.pathsep)
         for path in paths:
             if os.path.exists(os.path.join(path, filename)):
                 return os.path.abspath(os.path.join(path, filename))
@@ -286,19 +286,18 @@ class MessengerApp(object):
             print("COMMAND='%s'" % str(cmd))
         #print("ENV='%s'" % str(os.environ.copy()))
         try:
-            if os.name=="nt":
-                # Windows handles python launch by replacing script 'filename' 
with
-                # 'python abspath-to-filename' in cmdline arg list.
-                if cmd[0].endswith('.py'):
-                    foundfile = self.findfile(cmd[0], os.environ['PATH'])
-                    if foundfile is None:
-                        foundfile = self.findfile(cmd[0], 
os.environ['PYTHONPATH'])
-                        msg = "Unable to locate file '%s' in PATH or 
PYTHONPATH" % cmd[0]
-                        raise Skipped("Skipping test - %s" % msg)
-
-                    del cmd[0:1]
-                    cmd.insert(0, foundfile)
-                    cmd.insert(0, sys.executable)
+            # Handle python launch by replacing script 'filename' with
+            # 'python abspath-to-filename' in cmdline arg list.
+            if cmd[0].endswith('.py'):
+                foundfile = self.findfile(cmd[0], os.environ['PATH'])
+                if foundfile is None:
+                    foundfile = self.findfile(cmd[0], os.environ['PYTHONPATH'])
+                    msg = "Unable to locate file '%s' in PATH or PYTHONPATH" % 
cmd[0]
+                    raise Skipped("Skipping test - %s" % msg)
+
+                del cmd[0:1]
+                cmd.insert(0, foundfile)
+                cmd.insert(0, sys.executable)
             self._process = Popen(cmd, stdout=PIPE, stderr=STDOUT,
                                   bufsize=4096, universal_newlines=True)
         except OSError:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to