You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2015/06/22 14:57:04 UTC

[01/34] qpid-proton git commit: PROTON-490: futurize proton-c

Repository: qpid-proton
Updated Branches:
  refs/heads/master 653f4e5fe -> 17594bc3f


PROTON-490: futurize 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/677729af
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/677729af
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/677729af

Branch: refs/heads/master
Commit: 677729af4f4eea3076bfe493ad217b65aa125178
Parents: 81085e3
Author: Ken Giusti <kg...@apache.org>
Authored: Thu Apr 16 14:13:54 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Apr 20 12:45:16 2015 -0400

----------------------------------------------------------------------
 proton-c/mllib/__init__.py        | 10 +++-
 proton-c/mllib/dom.py             |  5 +-
 proton-c/mllib/parsers.py         |  3 +-
 proton-c/mllib/transforms.py      |  3 +-
 proton-c/src/codec/encodings.h.py | 17 ++++---
 proton-c/src/protocol.h.py        | 91 +++++++++++++++++-----------------
 6 files changed, 70 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/677729af/proton-c/mllib/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/__init__.py b/proton-c/mllib/__init__.py
index 9aa1e56..c6fccf1 100644
--- a/proton-c/mllib/__init__.py
+++ b/proton-c/mllib/__init__.py
@@ -22,16 +22,22 @@ This module provides document parsing and transformation utilities for
 both SGML and XML.
 """
 
-import os, dom, transforms, parsers, sys
+from __future__ import absolute_import
+
+import os, sys
 import xml.sax, types
 from xml.sax.handler import ErrorHandler
 from xml.sax.xmlreader import InputSource
 from cStringIO import StringIO
 
+from . import dom
+from . import transforms
+from . import parsers
+
 def transform(node, *args):
   result = node
   for t in args:
-    if isinstance(t, types.ClassType):
+    if isinstance(t, type):
       t = t()
     result = result.dispatch(t)
   return result

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/677729af/proton-c/mllib/dom.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/dom.py b/proton-c/mllib/dom.py
index 486f708..4cbac26 100644
--- a/proton-c/mllib/dom.py
+++ b/proton-c/mllib/dom.py
@@ -24,8 +24,8 @@ Simple DOM for both SGML and XML documents.
 from __future__ import division
 from __future__ import generators
 from __future__ import nested_scopes
+from __future__ import absolute_import
 
-import transforms
 
 class Container:
 
@@ -109,6 +109,7 @@ class Node(Container, Component, Dispatcher):
       return nd
 
   def text(self):
+    from . import transforms
     return self.dispatch(transforms.Text())
 
   def tag(self, name, *attrs, **kwargs):
@@ -238,7 +239,7 @@ class Flatten(View):
     sources = [iter(self.source)]
     while sources:
       try:
-        nd = sources[-1].next()
+        nd = next(sources[-1])
         if isinstance(nd, Tree):
           sources.append(iter(nd.children))
         else:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/677729af/proton-c/mllib/parsers.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/parsers.py b/proton-c/mllib/parsers.py
index 3e7cc10..e71018d 100644
--- a/proton-c/mllib/parsers.py
+++ b/proton-c/mllib/parsers.py
@@ -20,9 +20,10 @@
 """
 Parsers for SGML and XML to dom.
 """
+from __future__ import absolute_import
 
 import sgmllib, xml.sax.handler
-from dom import *
+from .dom import *
 
 class Parser:
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/677729af/proton-c/mllib/transforms.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/transforms.py b/proton-c/mllib/transforms.py
index 69d9912..383add3 100644
--- a/proton-c/mllib/transforms.py
+++ b/proton-c/mllib/transforms.py
@@ -20,8 +20,9 @@
 """
 Useful transforms for dom objects.
 """
+from __future__ import absolute_import
 
-import dom
+from . import dom
 from cStringIO import StringIO
 
 class Visitor:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/677729af/proton-c/src/codec/encodings.h.py
----------------------------------------------------------------------
diff --git a/proton-c/src/codec/encodings.h.py b/proton-c/src/codec/encodings.h.py
index 71fb9ea..9f08c6c 100755
--- a/proton-c/src/codec/encodings.h.py
+++ b/proton-c/src/codec/encodings.h.py
@@ -18,16 +18,17 @@
 # under the License.
 #
 
+from __future__ import print_function
 import mllib, optparse, os, sys
 
 xml = os.path.join(os.path.dirname(__file__), "types.xml")
 doc = mllib.xml_parse(xml)
 
-print "/* generated from %s */" % xml
-print "#ifndef _PROTON_ENCODINGS_H"
-print "#define _PROTON_ENCODINGS_H 1"
-print
-print "#define PNE_DESCRIPTOR          (0x00)"
+print("/* generated from %s */" % xml)
+print("#ifndef _PROTON_ENCODINGS_H")
+print("#define _PROTON_ENCODINGS_H 1")
+print()
+print("#define PNE_DESCRIPTOR          (0x00)")
 
 for enc in doc.query["amqp/section/type/encoding"]:
   name = enc["@name"] or enc.parent["@name"]
@@ -35,7 +36,7 @@ for enc in doc.query["amqp/section/type/encoding"]:
   if name == "ieee-754":
     name = enc.parent["@name"]
   cname = "PNE_" + name.replace("-", "_").upper()
-  print "#define %s%s(%s)" % (cname, " "*(20-len(cname)), enc["@code"])
+  print("#define %s%s(%s)" % (cname, " "*(20-len(cname)), enc["@code"]))
 
-print
-print "#endif /* encodings.h */"
+print()
+print("#endif /* encodings.h */")

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/677729af/proton-c/src/protocol.h.py
----------------------------------------------------------------------
diff --git a/proton-c/src/protocol.h.py b/proton-c/src/protocol.h.py
index 76a2391..bbc0dfe 100644
--- a/proton-c/src/protocol.h.py
+++ b/proton-c/src/protocol.h.py
@@ -18,20 +18,21 @@
 # under the License.
 #
 
+from __future__ import print_function
 from protocol import *
 
-print "/* generated */"
-print "#ifndef _PROTON_PROTOCOL_H"
-print "#define _PROTON_PROTOCOL_H 1"
-print
-print "#include \"proton/type_compat.h\""
+print("/* generated */")
+print("#ifndef _PROTON_PROTOCOL_H")
+print("#define _PROTON_PROTOCOL_H 1")
+print()
+print("#include \"proton/type_compat.h\"")
 
 fields = {}
 
 for type in TYPES:
   fidx = 0
   for f in type.query["field"]:
-    print "#define %s_%s (%s)" % (field_kw(type), field_kw(f), fidx)
+    print("#define %s_%s (%s)" % (field_kw(type), field_kw(f), fidx))
     fidx += 1
 
 idx = 0
@@ -39,14 +40,14 @@ idx = 0
 for type in TYPES:
   desc = type["descriptor"]
   name = type["@name"].upper().replace("-", "_")
-  print "#define %s_SYM (\"%s\")" % (name, desc["@name"])
+  print("#define %s_SYM (\"%s\")" % (name, desc["@name"]))
   hi, lo = [int(x, 0) for x in desc["@code"].split(":")]
   code = (hi << 32) + lo
-  print "#define %s ((uint64_t) %s)" % (name, code)
+  print("#define %s ((uint64_t) %s)" % (name, code))
   fields[code] = (type["@name"], [f["@name"] for f in type.query["field"]])
   idx += 1
 
-print """
+print("""
 #include <stddef.h>
 
 typedef struct {
@@ -61,43 +62,43 @@ extern const uint16_t FIELD_NAME[];
 extern const uint16_t FIELD_FIELDS[];
 extern const unsigned char FIELD_MIN;
 extern const unsigned char FIELD_MAX;
-"""
+""")
 
-print "#ifdef DEFINE_FIELDS"
+print("#ifdef DEFINE_FIELDS")
 
-print 'struct FIELD_STRINGS {'
-print '  const char FIELD_STRINGS_NULL[sizeof("")];'
+print('struct FIELD_STRINGS {')
+print('  const char FIELD_STRINGS_NULL[sizeof("")];')
 strings = set()
 for name, fnames in fields.values():
     strings.add(name)
     strings.update(fnames)
 for str in strings:
     istr = str.replace("-", "_");
-    print '  const char FIELD_STRINGS_%s[sizeof("%s")];' % (istr, str)
-print "};"
-print
-print 'const struct FIELD_STRINGS FIELD_STRINGS = {'
-print '  "",'
+    print('  const char FIELD_STRINGS_%s[sizeof("%s")];' % (istr, str))
+print("};")
+print()
+print('const struct FIELD_STRINGS FIELD_STRINGS = {')
+print('  "",')
 for str in strings:
-    print '  "%s",'% str
-print "};"
-print 'const char * const FIELD_STRINGPOOL = (const char * const) &FIELD_STRINGS;'
-print
-print "/* This is an array of offsets into FIELD_STRINGPOOL */"
-print "const uint16_t FIELD_NAME[] = {"
-print "  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_NULL),"
+    print('  "%s",'% str)
+print("};")
+print('const char * const FIELD_STRINGPOOL = (const char * const) &FIELD_STRINGS;')
+print()
+print("/* This is an array of offsets into FIELD_STRINGPOOL */")
+print("const uint16_t FIELD_NAME[] = {")
+print("  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_NULL),")
 index = 1
 for i in range(256):
   if i in fields:
     name, fnames = fields[i]
     iname = name.replace("-", "_");
-    print '  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_%s), /* %d */' % (iname, index)
+    print('  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_%s), /* %d */' % (iname, index))
     index += 1
-print "};"
+print("};")
 
-print "/* This is an array of offsets into FIELD_STRINGPOOL */"
-print "const uint16_t FIELD_FIELDS[] = {"
-print "  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_NULL),"
+print("/* This is an array of offsets into FIELD_STRINGPOOL */")
+print("const uint16_t FIELD_FIELDS[] = {")
+print("  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_NULL),")
 index = 1
 for i in range(256):
   if i in fields:
@@ -105,11 +106,11 @@ for i in range(256):
     if fnames:
       for f in fnames:
         ifname = f.replace("-", "_");
-        print '  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_%s), /* %d (%s) */' % (ifname, index, name)
+        print('  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_%s), /* %d (%s) */' % (ifname, index, name))
         index += 1
-print "};"
+print("};")
 
-print "const pn_fields_t FIELDS[] = {"
+print("const pn_fields_t FIELDS[] = {")
 
 name_count = 1
 field_count = 1
@@ -124,21 +125,21 @@ for i in range(field_min, field_max+1):
   if i in fields:
     name, fnames = fields[i]
     if fnames:
-      print '  {%d, %d, %d}, /* %d (%s) */' % (name_count, field_count, len(fnames), i, name)
+      print('  {%d, %d, %d}, /* %d (%s) */' % (name_count, field_count, len(fnames), i, name))
       field_count += len(fnames)
     else:
-      print '  {%d, 0, 0}, /* %d (%s) */' % (name_count, i, name)
+      print('  {%d, 0, 0}, /* %d (%s) */' % (name_count, i, name))
     name_count += 1
     if i>field_max: field_max = i
     if i<field_min: field_min = i
   else:
-    print '  {0, 0, 0}, /* %d */' % i
-
-print "};"
-print
-print 'const unsigned char FIELD_MIN = %d;' % field_min
-print 'const unsigned char FIELD_MAX = %d;' % field_max
-print
-print "#endif"
-print
-print "#endif /* protocol.h */"
+    print('  {0, 0, 0}, /* %d */' % i)
+
+print("};")
+print()
+print('const unsigned char FIELD_MIN = %d;' % field_min)
+print('const unsigned char FIELD_MAX = %d;' % field_max)
+print()
+print("#endif")
+print()
+print("#endif /* protocol.h */")


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[18/34] qpid-proton git commit: Merge branch 'master' into kgiusti-python3

Posted by kg...@apache.org.
Merge branch 'master' into kgiusti-python3


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

Branch: refs/heads/master
Commit: 758295d2bb601dc34b6892027616bf0644674d38
Parents: 64a7ce2 fe3290b
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Apr 29 15:36:52 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Apr 29 15:36:52 2015 -0400

----------------------------------------------------------------------
 CMakeLists.txt                                  |  7 ++++++
 proton-c/include/proton/sasl.h                  |  2 +-
 proton-c/src/sasl/cyrus_sasl.c                  |  6 ++++-
 proton-c/src/sasl/none_sasl.c                   |  5 ++--
 proton-c/src/tests/CMakeLists.txt               | 10 +++-----
 .../apache/qpid/proton/engine/Transport.java    |  4 +++
 .../qpid/proton/engine/impl/FrameParser.java    | 10 +++++++-
 .../qpid/proton/engine/impl/FrameWriter.java    |  7 ++++++
 .../qpid/proton/engine/impl/TransportImpl.java  | 12 +++++++++
 proton-j/src/main/resources/cengine.py          |  5 +++-
 tests/python/proton_tests/engine.py             | 21 ++++++++++++++++
 tests/python/proton_tests/messenger.py          | 26 +++++++++++---------
 12 files changed, 92 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/758295d2/tests/python/proton_tests/engine.py
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/758295d2/tests/python/proton_tests/messenger.py
----------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[11/34] qpid-proton git commit: PROTON-490: get the python unit test to run in Python 3

Posted by kg...@apache.org.
PROTON-490: get the python unit test to run in Python 3


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

Branch: refs/heads/master
Commit: 99299d3b33e5e5ae9fbeff51ac6b7b25cacd6e85
Parents: efa1f68
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Apr 22 16:54:25 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Fri Apr 24 15:59:03 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/cproton.i          |  12 ++-
 proton-c/bindings/python/proton/__init__.py |  97 ++++++++++--------
 proton-c/bindings/python/proton/reactor.py  |  10 +-
 proton-c/bindings/python/proton/utils.py    |  14 +--
 proton-c/bindings/python/proton/wrapper.py  |  12 ++-
 proton-j/src/main/resources/cmessage.py     |   2 +-
 tests/python/proton-test                    |  28 ++---
 tests/python/proton_tests/codec.py          | 109 ++++++++++----------
 tests/python/proton_tests/common.py         |   9 +-
 tests/python/proton_tests/engine.py         | 125 +++++++++++++----------
 tests/python/proton_tests/interop.py        |  23 +++--
 tests/python/proton_tests/message.py        |   6 +-
 tests/python/proton_tests/messenger.py      |   1 +
 tests/python/proton_tests/sasl.py           |  11 +-
 tests/python/proton_tests/transport.py      |  25 ++---
 tests/python/proton_tests/utils.py          |   1 +
 tests/tools/apps/python/msgr-recv.py        |   5 +
 tests/tools/apps/python/msgr-send.py        |   5 +
 tests/tools/soak-check                      |   5 +-
 19 files changed, 279 insertions(+), 221 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/proton-c/bindings/python/cproton.i
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/cproton.i b/proton-c/bindings/python/cproton.i
index 5744a2d..328d68a 100644
--- a/proton-c/bindings/python/cproton.i
+++ b/proton-c/bindings/python/cproton.i
@@ -38,6 +38,9 @@
 %cstring_output_allocate_size(char **ALLOC_OUTPUT, size_t *ALLOC_SIZE, free(*$1));
 %cstring_output_maxsize(char *OUTPUT, size_t MAX_OUTPUT_SIZE)
 
+%include <pybuffer.i>
+%pybuffer_binary(const char *BIN_IN, size_t BIN_LEN)
+
 // Typemap for methods that return binary data:
 // force the return type as binary - this is necessary for Python3
 %typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (char *BIN_OUT, size_t *BIN_SIZE)
@@ -110,7 +113,10 @@
 int pn_message_encode(pn_message_t *msg, char *BIN_OUT, size_t *BIN_SIZE);
 %ignore pn_message_encode;
 
-ssize_t pn_link_send(pn_link_t *transport, char *STRING, size_t LENGTH);
+int pn_message_decode(pn_message_t *msg, const char *BIN_IN, size_t BIN_LEN);
+%ignore pn_message_encode;
+
+ssize_t pn_link_send(pn_link_t *transport, const char *BIN_IN, size_t BIN_LEN);
 %ignore pn_link_send;
 
 %rename(pn_link_recv) wrap_pn_link_recv;
@@ -127,7 +133,7 @@ ssize_t pn_link_send(pn_link_t *transport, char *STRING, size_t LENGTH);
 %}
 %ignore pn_link_recv;
 
-ssize_t pn_transport_push(pn_transport_t *transport, char *STRING, size_t LENGTH);
+ssize_t pn_transport_push(pn_transport_t *transport, const char *BIN_IN, size_t BIN_LEN);
 %ignore pn_transport_push;
 
 %rename(pn_transport_peek) wrap_pn_transport_peek;
@@ -163,7 +169,7 @@ ssize_t pn_transport_push(pn_transport_t *transport, char *STRING, size_t LENGTH
 %}
 %ignore pn_delivery_tag;
 
-ssize_t pn_data_decode(pn_data_t *data, char *STRING, size_t LENGTH);
+ssize_t pn_data_decode(pn_data_t *data, const char *BIN_IN, size_t BIN_LEN);
 %ignore pn_data_decode;
 
 %rename(pn_data_encode) wrap_pn_data_encode;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
index 8871eda..399aec7 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -79,16 +79,16 @@ except ImportError:
   rand = random.Random()
   rand.seed((os.getpid(), time.time(), socket.gethostname()))
   def random_uuid():
-    bytes = [rand.randint(0, 255) for i in xrange(16)]
+    data = [rand.randint(0, 255) for i in xrange(16)]
 
     # From RFC4122, the version bits are set to 0100
-    bytes[7] &= 0x0F
-    bytes[7] |= 0x40
+    data[7] &= 0x0F
+    data[7] |= 0x40
 
     # From RFC4122, the top two bits of byte 8 get set to 01
-    bytes[8] &= 0x3F
-    bytes[8] |= 0x80
-    return "".join(map(chr, bytes))
+    data[8] &= 0x3F
+    data[8] |= 0x80
+    return "".join(map(chr, data))
 
   def uuid4():
     return uuid.UUID(bytes=random_uuid())
@@ -805,7 +805,7 @@ class Message(object):
     self.annotations = None
     self.properties = None
     self.body = body
-    for k,v in kwargs.iteritems():
+    for k,v in six.iteritems(kwargs):
       getattr(self, k)          # Raise exception if it's not a valid attribute.
       setattr(self, k, v)
 
@@ -846,19 +846,19 @@ class Message(object):
     props = Data(pn_message_properties(self._msg))
     body = Data(pn_message_body(self._msg))
 
-    if next(inst):
+    if inst.next():
       self.instructions = inst.get_object()
     else:
       self.instructions = None
-    if next(ann):
+    if ann.next():
       self.annotations = ann.get_object()
     else:
       self.annotations = None
-    if next(props):
+    if props.next():
       self.properties = props.get_object()
     else:
       self.properties = None
-    if next(body):
+    if body.next():
       self.body = body.get_object()
     else:
       self.body = None
@@ -1106,7 +1106,7 @@ The group-id for any replies.
         return data
 
   def decode(self, data):
-    self._check(pn_message_decode(self._msg, data, len(data)))
+    self._check(pn_message_decode(self._msg, data))
     self._post_decode()
 
   def send(self, sender, tag=None):
@@ -1803,7 +1803,7 @@ class Data:
     @type s: string
     @param s: the symbol name
     """
-    self._check(pn_data_put_symbol(self._data, s))
+    self._check(pn_data_put_symbol(self._data, s.encode('ascii')))
 
   def get_list(self):
     """
@@ -1941,7 +1941,7 @@ class Data:
     If the current node is a char, returns its value, returns 0
     otherwise.
     """
-    return char(unichr(pn_data_get_char(self._data)))
+    return char(six.unichr(pn_data_get_char(self._data)))
 
   def get_ulong(self):
     """
@@ -2031,7 +2031,7 @@ class Data:
     If the current node is a symbol, returns its value, returns ""
     otherwise.
     """
-    return symbol(pn_data_get_symbol(self._data))
+    return symbol(pn_data_get_symbol(self._data).decode('ascii'))
 
   def copy(self, src):
     self._check(pn_data_copy(self._data, src._data))
@@ -2064,9 +2064,9 @@ class Data:
     if self.enter():
       try:
         result = {}
-        while next(self):
+        while self.next():
           k = self.get_object()
-          if next(self):
+          if self.next():
             v = self.get_object()
           else:
             v = None
@@ -2088,7 +2088,7 @@ class Data:
     if self.enter():
       try:
         result = []
-        while next(self):
+        while self.next():
           result.append(self.get_object())
       finally:
         self.exit()
@@ -2097,9 +2097,9 @@ class Data:
   def get_py_described(self):
     if self.enter():
       try:
-        next(self)
+        self.next()
         descriptor = self.get_object()
-        next(self)
+        self.next()
         value = self.get_object()
       finally:
         self.exit()
@@ -2126,12 +2126,12 @@ class Data:
     if self.enter():
       try:
         if described:
-          next(self)
+          self.next()
           descriptor = self.get_object()
         else:
           descriptor = UNDESCRIBED
         elements = []
-        while next(self):
+        while self.next():
           elements.append(self.get_object())
       finally:
         self.exit()
@@ -2309,7 +2309,7 @@ def dat2obj(dimpl):
   if dimpl:
     d = Data(dimpl)
     d.rewind()
-    next(d)
+    d.next()
     obj = d.get_object()
     d.rewind()
     return obj
@@ -2334,21 +2334,34 @@ def millis2timeout(millis):
   return millis2secs(millis)
 
 def unicode2utf8(string):
+    """Some Proton APIs expect a null terminated string. Convert python text
+    types to UTF8 to avoid zero bytes introduced by other multi-byte encodings.
+    This method will throw if the string cannot be converted.
+    """
     if string is None:
         return None
-    if isinstance(string, six.text_type):
-        return string.encode('utf8')
-    elif isinstance(string, str):
-        return string
-    else:
-        raise TypeError("Unrecognized string type: %r" % string)
+    if six.PY2:
+        if isinstance(string, unicode):
+            return string.encode('utf-8')
+        elif isinstance(string, str):
+            return string
+    elif six.PY3:
+        # decoding a string results in bytes
+        if isinstance(string, str):
+            string = string.encode('utf-8')
+            # fall through
+        if isinstance(string, bytes):
+            return string.decode('utf-8')
+    raise TypeError("Unrecognized string type: %r (%s)" % (string, type(string)))
 
 def utf82unicode(string):
+    """Covert C strings returned from proton-c into python unicode"""
     if string is None:
         return None
     if isinstance(string, six.text_type):
+        # already unicode
         return string
-    elif isinstance(string, str):
+    elif isinstance(string, six.binary_type):
         return string.decode('utf8')
     else:
         raise TypeError("Unrecognized string type")
@@ -2872,11 +2885,16 @@ class Sender(Link):
   def offered(self, n):
     pn_link_offered(self._impl, n)
 
-  def stream(self, bytes):
+  def stream(self, data):
     """
-    Send specified bytes as part of the current delivery
+    Send specified data as part of the current delivery
+
+    @type data: binary
+    @param data: data to send
     """
-    return self._check(pn_link_send(self._impl, bytes))
+    #if six.PY3 and isinstance(data, six.text_type):
+    #    data = data.encode('utf-8')
+    return self._check(pn_link_send(self._impl, data))
 
   def send(self, obj, tag=None):
     """
@@ -2913,12 +2931,12 @@ class Receiver(Link):
     pn_link_flow(self._impl, n)
 
   def recv(self, limit):
-    n, bytes = pn_link_recv(self._impl, limit)
+    n, binary = pn_link_recv(self._impl, limit)
     if n == PN_EOS:
       return None
     else:
       self._check(n)
-      return bytes
+      return binary
 
   def drain(self, n):
     pn_link_drain(self._impl, n)
@@ -3232,9 +3250,9 @@ class Transport(Wrapper):
     else:
       return self._check(c)
 
-  def push(self, bytes):
-    n = self._check(pn_transport_push(self._impl, bytes))
-    if n != len(bytes):
+  def push(self, binary):
+    n = self._check(pn_transport_push(self._impl, binary))
+    if n != len(binary):
       raise OverflowError("unable to process all bytes")
 
   def close_tail(self):
@@ -3370,7 +3388,6 @@ class SASL(Wrapper):
   def done(self, outcome):
     pn_sasl_done(self._sasl, outcome)
 
-
 class SSLException(TransportException):
   pass
 
@@ -3853,7 +3870,7 @@ class Url(object):
       If specified, replaces corresponding part in url string.
     """
     if url:
-      self._url = pn_url_parse(str(url))
+      self._url = pn_url_parse(unicode2utf8(str(url)))
       if not self._url: raise ValueError("Invalid URL '%s'" % url)
     else:
       self._url = pn_url()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index a9bd3cc..dd32648 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -482,9 +482,9 @@ class Connector(Handler):
         self.ssl_domain = None
 
     def _connect(self, connection):
-        url = next(self.address)
+        url = self.address.next()
         # IoHandler uses the hostname to determine where to try to connect to
-        connection.hostname = "%s:%i" % (url.host, url.port)
+        connection.hostname = "%s:%s" % (url.host, url.port)
         logging.info("connecting to %s..." % connection.hostname)
 
         transport = Transport()
@@ -517,7 +517,7 @@ class Connector(Handler):
         if self.connection and self.connection.state & Endpoint.LOCAL_ACTIVE:
             if self.reconnect:
                 event.transport.unbind()
-                delay = next(self.reconnect)
+                delay = self.reconnect.next()
                 if delay == 0:
                     logging.info("Disconnected, reconnecting...")
                     self._connect(self.connection)
@@ -667,7 +667,7 @@ class Container(Reactor):
         Various LinkOptions can be specified to further control the
         attachment.
         """
-        if isinstance(context, basestring):
+        if isinstance(context, six.string_types):
             context = Url(context)
         if isinstance(context, Url) and not target:
             target = context.path
@@ -708,7 +708,7 @@ class Container(Reactor):
         Various LinkOptions can be specified to further control the
         attachment.
         """
-        if isinstance(context, basestring):
+        if isinstance(context, six.string_types):
             context = Url(context)
         if isinstance(context, Url) and not source:
             source = context.path

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/proton-c/bindings/python/proton/utils.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/utils.py b/proton-c/bindings/python/proton/utils.py
index 0d7f39e..7b8ec13 100644
--- a/proton-c/bindings/python/proton/utils.py
+++ b/proton-c/bindings/python/proton/utils.py
@@ -17,6 +17,7 @@
 # under the License.
 #
 import collections, socket, time, threading
+import six
 from six.moves import queue as Queue
 
 from proton import ConnectionException, Delivery, Endpoint, Handler, LinkException, Message
@@ -24,11 +25,6 @@ from proton import ProtonException, Timeout, Url
 from proton.reactor import Container
 from proton.handlers import MessagingHandler, IncomingMessageHandler
 
-def utf8(s):
-    if isinstance(s, unicode):
-        return s.encode('utf8')
-    else:
-        return s
 
 class BlockingLink(object):
     def __init__(self, connection, link):
@@ -196,13 +192,13 @@ class BlockingConnection(Handler):
         self.container = container or Container()
         self.container.timeout = self.timeout
         self.container.start()
-        self.url = Url(utf8(url)).defaults()
+        self.url = Url(url).defaults()
         self.conn = self.container.connect(url=self.url, handler=self, ssl_domain=ssl_domain, reconnect=False)
         self.wait(lambda: not (self.conn.state & Endpoint.REMOTE_UNINIT),
                   msg="Opening connection")
 
     def create_sender(self, address, handler=None, name=None, options=None):
-        return BlockingSender(self, self.container.create_sender(self.conn, utf8(address), name=utf8(name), handler=handler, options=options))
+        return BlockingSender(self, self.container.create_sender(self.conn, address, name=name, handler=handler, options=options))
 
     def create_receiver(self, address, credit=None, dynamic=False, handler=None, name=None, options=None):
         prefetch = credit
@@ -213,7 +209,7 @@ class BlockingConnection(Handler):
         else:
             fetcher = Fetcher(self, credit)
         return BlockingReceiver(
-            self, self.container.create_receiver(self.conn, utf8(address), name=utf8(name), dynamic=dynamic, handler=handler or fetcher, options=options), fetcher, credit=prefetch)
+            self, self.container.create_receiver(self.conn, address, name=name, dynamic=dynamic, handler=handler or fetcher, options=options), fetcher, credit=prefetch)
 
     def close(self):
         self.conn.close()
@@ -314,7 +310,7 @@ class SyncRequestResponse(IncomingMessageHandler):
         if not self.address and not request.address:
             raise ValueError("Request message has no address: %s" % request)
         request.reply_to = self.reply_to
-        request.correlation_id = correlation_id = next(self.correlation_id)
+        request.correlation_id = correlation_id = self.correlation_id.next()
         self.sender.send(request)
         def wakeup():
             return self.response and (self.response.correlation_id == correlation_id)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/proton-c/bindings/python/proton/wrapper.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/wrapper.py b/proton-c/bindings/python/proton/wrapper.py
index 2911d3a..d3923cf 100644
--- a/proton-c/bindings/python/proton/wrapper.py
+++ b/proton-c/bindings/python/proton/wrapper.py
@@ -81,11 +81,15 @@ class Wrapper(object):
     def __hash__(self):
         return hash(addressof(self._impl))
 
-    def __cmp__(self, other):
+    def __eq__(self, other):
         if isinstance(other, Wrapper):
-            return cmp(addressof(self._impl), addressof(other._impl))
-        else:
-            return -1
+            return addressof(self._impl) == addressof(other._impl)
+        return False
+
+    def __ne__(self, other):
+        if isinstance(other, Wrapper):
+            return addressof(self._impl) != addressof(other._impl)
+        return True
 
     def __del__(self):
         pn_decref(self._impl)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/proton-j/src/main/resources/cmessage.py
----------------------------------------------------------------------
diff --git a/proton-j/src/main/resources/cmessage.py b/proton-j/src/main/resources/cmessage.py
index 6035d54..a338da2 100644
--- a/proton-j/src/main/resources/cmessage.py
+++ b/proton-j/src/main/resources/cmessage.py
@@ -215,7 +215,7 @@ def pn_message_properties(msg):
 def pn_message_body(msg):
   return msg.body
 
-def pn_message_decode(msg, data, n):
+def pn_message_decode(msg, data):
   n = msg.impl.decode(array(data, 'b'), 0, len(data))
   msg.post_decode()
   return n

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/python/proton-test
----------------------------------------------------------------------
diff --git a/tests/python/proton-test b/tests/python/proton-test
index 66113dc..5073ab4 100755
--- a/tests/python/proton-test
+++ b/tests/python/proton-test
@@ -20,6 +20,7 @@
 
 # TODO: summarize, test harness preconditions (e.g. broker is alive)
 
+import six
 import logging, optparse, os, struct, sys, time, traceback, types, cgi
 from fnmatch import fnmatchcase as match
 from getopt import GetoptError
@@ -32,7 +33,7 @@ levels = {
   "ERROR": ERROR
   }
 
-sorted_levels = [(v, k) for k, v in levels.items()]
+sorted_levels = [(v, k) for k, v in list(levels.items())]
 sorted_levels.sort()
 sorted_levels = [v for k, v in sorted_levels]
 
@@ -446,9 +447,9 @@ def run_test(name, test, config):
     if interceptor.last != "\n":
       sys.stdout.write("\n")
     sys.stdout.write(output)
-  print " %s" % colorize_word(runner.status())
+  print(" %s" % colorize_word(runner.status()))
   if runner.failed() or runner.skipped():
-    print runner.get_formatted_exception_trace()
+    print(runner.get_formatted_exception_trace())
   root.setLevel(level)
   filter.patterns = patterns
   return TestResult(end - start,
@@ -554,7 +555,7 @@ class FunctionScanner(PatternMatcher):
 class ClassScanner(PatternMatcher):
 
   def inspect(self, obj):
-    return type(obj) in (types.ClassType, types.TypeType) and self.matches(obj.__name__)
+    return type(obj) in six.class_types and self.matches(obj.__name__)
 
   def descend(self, cls):
     # the None is required for older versions of python
@@ -565,8 +566,7 @@ class ClassScanner(PatternMatcher):
     names.sort()
     for name in names:
       obj = getattr(cls, name)
-      t = type(obj)
-      if t == types.MethodType and name.startswith("test"):
+      if six.callable(obj) and name.startswith("test"):
         yield MethodTest(cls, name)
 
 class ModuleScanner:
@@ -633,7 +633,7 @@ def runthrough():
   start = time.time()
   for t in filtered:
     if list_only:
-      print t.name()
+      print(t.name())
     else:
       st = t.run()
       if xmlr:
@@ -667,22 +667,22 @@ def runthrough():
       skip = "skip"
     else:
       skip = "pass"
-    print colorize("Totals:", 1),
+    six.print_(colorize("Totals:", 1), end=' ')
     totals = [colorize_word("total", "%s tests" % total),
               colorize_word(_pass, "%s passed" % passed),
               colorize_word(skip, "%s skipped" % skipped),
               colorize_word(ign, "%s ignored" % len(ignored)),
               colorize_word(outcome, "%s failed" % failed)]
-    print ", ".join(totals),
+    six.print_(", ".join(totals), end=' ')
     if opts.hoe and failed > 0:
-      print " -- (halted after %s)" % run
+      print(" -- (halted after %s)" % run)
     else:
-      print
+      print()
     if opts.time and run > 0:
-      print colorize("Timing:", 1),
+      six.print_(colorize("Timing:", 1), end=' ')
       timing = [colorize_word("elapsed", "%.2fs elapsed" % (end - start)),
                 colorize_word("average", "%.2fs average" % ((end - start)/run))]
-      print ", ".join(timing)
+      print(", ".join(timing))
 
   if xmlr:
      xmlr.end()
@@ -697,7 +697,7 @@ while limit == 0 or count < limit:
   if runthrough():
     failures = True
     if count > 1:
-      print " -- (failures after %s runthroughs)" % count
+      print(" -- (failures after %s runthroughs)" % count)
   else:
     continue
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/python/proton_tests/codec.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/codec.py b/tests/python/proton_tests/codec.py
index e8893cf..e340732 100644
--- a/tests/python/proton_tests/codec.py
+++ b/tests/python/proton_tests/codec.py
@@ -18,13 +18,13 @@
 #
 
 import os, sys
+import six
 from . import common
 from proton import *
 try:
   from uuid import uuid4
 except ImportError:
   from proton import uuid4
-  
 
 class Test(common.Test):
 
@@ -37,58 +37,58 @@ class Test(common.Test):
 class DataTest(Test):
 
   def testTopLevelNext(self):
-    assert next(self.data) is None
+    assert self.data.next() is None
     self.data.put_null()
     self.data.put_bool(False)
     self.data.put_int(0)
-    assert next(self.data) is None
+    assert self.data.next() is None
     self.data.rewind()
-    assert next(self.data) == Data.NULL
-    assert next(self.data) == Data.BOOL
-    assert next(self.data) == Data.INT
-    assert next(self.data) is None
+    assert self.data.next() == Data.NULL
+    assert self.data.next() == Data.BOOL
+    assert self.data.next() == Data.INT
+    assert self.data.next() is None
 
   def testNestedNext(self):
-    assert next(self.data) is None
+    assert self.data.next() is None
     self.data.put_null()
-    assert next(self.data) is None
+    assert self.data.next() is None
     self.data.put_list()
-    assert next(self.data) is None
+    assert self.data.next() is None
     self.data.put_bool(False)
-    assert next(self.data) is None
+    assert self.data.next() is None
     self.data.rewind()
-    assert next(self.data) is Data.NULL
-    assert next(self.data) is Data.LIST
+    assert self.data.next() is Data.NULL
+    assert self.data.next() is Data.LIST
     self.data.enter()
-    assert next(self.data) is None
+    assert self.data.next() is None
     self.data.put_ubyte(0)
-    assert next(self.data) is None
+    assert self.data.next() is None
     self.data.put_uint(0)
-    assert next(self.data) is None
+    assert self.data.next() is None
     self.data.put_int(0)
-    assert next(self.data) is None
+    assert self.data.next() is None
     self.data.exit()
-    assert next(self.data) is Data.BOOL
-    assert next(self.data) is None
+    assert self.data.next() is Data.BOOL
+    assert self.data.next() is None
 
     self.data.rewind()
-    assert next(self.data) is Data.NULL
-    assert next(self.data) is Data.LIST
+    assert self.data.next() is Data.NULL
+    assert self.data.next() is Data.LIST
     assert self.data.enter()
-    assert next(self.data) is Data.UBYTE
-    assert next(self.data) is Data.UINT
-    assert next(self.data) is Data.INT
-    assert next(self.data) is None
+    assert self.data.next() is Data.UBYTE
+    assert self.data.next() is Data.UINT
+    assert self.data.next() is Data.INT
+    assert self.data.next() is None
     assert self.data.exit()
-    assert next(self.data) is Data.BOOL
-    assert next(self.data) is None
+    assert self.data.next() is Data.BOOL
+    assert self.data.next() is None
 
   def testEnterExit(self):
-    assert next(self.data) is None
+    assert self.data.next() is None
     assert not self.data.enter()
     self.data.put_list()
     assert self.data.enter()
-    assert next(self.data) is None
+    assert self.data.next() is None
     self.data.put_list()
     assert self.data.enter()
     self.data.put_list()
@@ -101,19 +101,19 @@ class DataTest(Test):
     assert self.data.get_list() == 1
     assert not self.data.exit()
     assert self.data.get_list() == 1
-    assert next(self.data) is None
+    assert self.data.next() is None
 
     self.data.rewind()
-    assert next(self.data) is Data.LIST
+    assert self.data.next() is Data.LIST
     assert self.data.get_list() == 1
     assert self.data.enter()
-    assert next(self.data) is Data.LIST
+    assert self.data.next() is Data.LIST
     assert self.data.get_list() == 1
     assert self.data.enter()
-    assert next(self.data) is Data.LIST
+    assert self.data.next() is Data.LIST
     assert self.data.get_list() == 0
     assert self.data.enter()
-    assert next(self.data) is None
+    assert self.data.next() is None
     assert self.data.exit()
     assert self.data.get_list() == 0
     assert self.data.exit()
@@ -129,7 +129,7 @@ class DataTest(Test):
       putter(v)
     except Exception:
       etype, value, trace = sys.exc_info()
-      raise etype, "%s(%r): %s" % (putter.__name__, v, value), trace
+      six.reraise(etype, etype("%s(%r): %s" % (putter.__name__, v, value)), trace)
     return putter
 
   # (bits, signed) for each integer type
@@ -148,12 +148,12 @@ class DataTest(Test):
     values = [0, 1, 2, 5, 42]
     if signed:
       min, max = -2**(bits-1), 2**(bits-1)-1
-      values.append(max / 2)
+      values.append(max // 2)
       values += [-i for i in values if i]
       values += [min, max]
     else:
       max = 2**(bits) - 1
-      values += [max / 2, max]
+      values += [max // 2, max]
     return sorted(values)
 
   def _testArray(self, dtype, descriptor, atype, *values):
@@ -169,7 +169,7 @@ class DataTest(Test):
       self.put(putter, v)
     self.data.exit()
     self.data.rewind()
-    assert next(self.data) == Data.ARRAY
+    assert self.data.next() == Data.ARRAY
     count, described, type = self.data.get_array()
     assert count == len(values), count
     if dtype is None:
@@ -179,17 +179,17 @@ class DataTest(Test):
     assert type == aTYPE, type
     assert self.data.enter()
     if described:
-      assert next(self.data) == dTYPE
+      assert self.data.next() == dTYPE
       getter = getattr(self.data, "get_%s" % dtype)
       gotten = getter()
       assert gotten == descriptor, gotten
     if values:
       getter = getattr(self.data, "get_%s" % atype)
       for v in values:
-        assert next(self.data) == aTYPE
+        assert self.data.next() == aTYPE
         gotten = getter()
         assert gotten == v, gotten
-    assert next(self.data) is None
+    assert self.data.next() is None
     assert self.data.exit()
 
   def testStringArray(self):
@@ -231,7 +231,7 @@ class DataTest(Test):
     self.data.rewind()
 
     for v in values:
-      vtype = next(self.data)
+      vtype = self.data.next()
       assert vtype == ntype, vtype
       gotten = getter()
       assert eq(gotten, v), (gotten, v)
@@ -246,7 +246,7 @@ class DataTest(Test):
     cgetter = getattr(copy, "get_%s" % dtype)
 
     for v in values:
-      vtype = next(copy)
+      vtype = copy.next()
       assert vtype == ntype, vtype
       gotten = cgetter()
       assert eq(gotten, v), (gotten, v)
@@ -275,7 +275,8 @@ class DataTest(Test):
     self._test("double", 0, 1, 2, 3, 0.1, 0.2, 0.3, -1, -2, -3, -0.1, -0.2, -0.3)
 
   def testBinary(self):
-    self._test("binary", "this", "is", "a", "test", "of" "b\x00inary")
+    self._test("binary", six.b("this"), six.b("is"), six.b("a"), six.b("test"),
+               six.b("of" "b\x00inary"))
 
   def testSymbol(self):
     self._test("symbol", "this is a symbol test", "bleh", "blah")
@@ -284,7 +285,7 @@ class DataTest(Test):
     self._test("timestamp", 0, 12345, 1000000)
 
   def testChar(self):
-    self._test("char", 'a', 'b', 'c', u'\u1234')
+    self._test("char", 'a', 'b', 'c', six.u('\u1234'))
 
   def testUUID(self):
     self._test("uuid", uuid4(), uuid4(), uuid4())
@@ -296,7 +297,7 @@ class DataTest(Test):
     self._test("decimal64", 0, 1, 2, 3, 4, 2**60)
 
   def testDecimal128(self):
-    self._test("decimal128", "fdsaasdf;lkjjkl;", "x"*16 )
+    self._test("decimal128", six.b("fdsaasdf;lkjjkl;"), six.b("x"*16))
 
   def testCopy(self):
     self.data.put_described()
@@ -337,33 +338,33 @@ class DataTest(Test):
     obj = {symbol("key"): timestamp(1234),
            ulong(123): "blah",
            char("c"): "bleh",
-           u"desc": Described(symbol("url"), u"http://example.org"),
-           u"array": Array(UNDESCRIBED, Data.INT, 1, 2, 3),
-           u"list": [1, 2, 3, None, 4],
-           u"boolean": True}
+           six.u("desc"): Described(symbol("url"), six.u("http://example.org")),
+           six.u("array"): Array(UNDESCRIBED, Data.INT, 1, 2, 3),
+           six.u("list"): [1, 2, 3, None, 4],
+           six.u("boolean"): True}
     self.data.put_object(obj)
     enc = self.data.encode()
     data = Data()
     data.decode(enc)
     data.rewind()
-    assert next(data)
+    assert data.next()
     copy = data.get_object()
     assert copy == obj, (copy, obj)
 
   def testLookup(self):
-    obj = {symbol("key"): u"value",
+    obj = {symbol("key"): six.u("value"),
            symbol("pi"): 3.14159,
            symbol("list"): [1, 2, 3, 4]}
     self.data.put_object(obj)
     self.data.rewind()
-    next(self.data)
+    self.data.next()
     self.data.enter()
     self.data.narrow()
     assert self.data.lookup("pi")
     assert self.data.get_object() == 3.14159
     self.data.rewind()
     assert self.data.lookup("key")
-    assert self.data.get_object() == u"value"
+    assert self.data.get_object() == six.u("value")
     self.data.rewind()
     assert self.data.lookup("list")
     assert self.data.get_object() == [1, 2, 3, 4]

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py b/tests/python/proton_tests/common.py
index 585ea02..be9c75a 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -88,9 +88,9 @@ def pump_uni(src, dst, buffer_size=1024):
   elif p == 0 or c == 0:
     return False
   else:
-    bytes = src.peek(min(c, buffer_size))
-    dst.push(bytes)
-    src.pop(len(bytes))
+    binary = src.peek(min(c, buffer_size))
+    dst.push(binary)
+    src.pop(len(binary))
 
   return True
 
@@ -244,7 +244,8 @@ class MessengerApp(object):
                     del cmd[0:1]
                     cmd.insert(0, foundfile)
                     cmd.insert(0, sys.executable)
-            self._process = Popen(cmd, stdout=PIPE, stderr=STDOUT, bufsize=4096)
+            self._process = Popen(cmd, stdout=PIPE, stderr=STDOUT,
+                                  bufsize=4096, universal_newlines=True)
         except OSError:
             e = sys.exc_info()[1]
             print("ERROR: '%s'" % e)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index 7835792..4670562 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -21,6 +21,7 @@ from __future__ import absolute_import
 import os, gc
 from . import common
 from time import time, sleep
+import six
 from proton import *
 from .common import pump
 from proton.reactor import Reactor
@@ -36,6 +37,19 @@ if not hasattr(gc, "garbage"):
 #  + resuming
 #    - locally and remotely created deliveries with the same tag
 
+# Jython 2.5 needs this:
+try:
+    bytes()
+except:
+    bytes = str
+
+# and this...
+try:
+    bytearray()
+except:
+    def bytearray(x):
+        return six.b('\x00') * x
+
 OUTPUT_SIZE = 10*1024
 
 class Test(common.Test):
@@ -725,7 +739,7 @@ class TransferTest(Test):
     assert tag == "tag", tag
     assert d.writable
 
-    n = self.snd.send("this is a test")
+    n = self.snd.send(six.b("this is a test"))
     assert self.snd.advance()
     assert self.c1.work_head is None
 
@@ -738,7 +752,7 @@ class TransferTest(Test):
   def test_multiframe(self):
     self.rcv.flow(1)
     self.snd.delivery("tag")
-    msg = "this is a test"
+    msg = six.b("this is a test")
     n = self.snd.send(msg)
     assert n == len(msg)
 
@@ -749,24 +763,24 @@ class TransferTest(Test):
     assert d.tag == "tag", repr(d.tag)
     assert d.readable
 
-    bytes = self.rcv.recv(1024)
-    assert bytes == msg, (bytes, msg)
+    binary = self.rcv.recv(1024)
+    assert binary == msg, (binary, msg)
 
-    bytes = self.rcv.recv(1024)
-    assert bytes == ""
+    binary = self.rcv.recv(1024)
+    assert binary == six.b("")
 
-    msg = "this is more"
+    msg = six.b("this is more")
     n = self.snd.send(msg)
     assert n == len(msg)
     assert self.snd.advance()
 
     self.pump()
 
-    bytes = self.rcv.recv(1024)
-    assert bytes == msg, (bytes, msg)
+    binary = self.rcv.recv(1024)
+    assert binary == msg, (binary, msg)
 
-    bytes = self.rcv.recv(1024)
-    assert bytes is None
+    binary = self.rcv.recv(1024)
+    assert binary is None
 
   def test_disposition(self):
     self.rcv.flow(1)
@@ -774,7 +788,7 @@ class TransferTest(Test):
     self.pump()
 
     sd = self.snd.delivery("tag")
-    msg = "this is a test"
+    msg = six.b("this is a test")
     n = self.snd.send(msg)
     assert n == len(msg)
     assert self.snd.advance()
@@ -809,7 +823,7 @@ class TransferTest(Test):
     #fill up delivery buffer on sender
     for m in range(1024):
       sd = self.snd.delivery("tag%s" % m)
-      msg = "message %s" % m
+      msg = ("message %s" % m).encode('ascii')
       n = self.snd.send(msg)
       assert n == len(msg)
       assert self.snd.advance()
@@ -822,7 +836,7 @@ class TransferTest(Test):
       assert rd is not None, m
       assert rd.tag == ("tag%s" % m), (rd.tag, m)
       msg = self.rcv.recv(1024)
-      assert msg == ("message %s" % m), (msg, m)
+      assert msg == ("message %s" % m).encode('ascii'), (msg, m)
       rd.update(Delivery.ACCEPTED)
       rd.settle()
 
@@ -831,7 +845,7 @@ class TransferTest(Test):
     #add some new deliveries
     for m in range(1024, 1450):
       sd = self.snd.delivery("tag%s" % m)
-      msg = "message %s" % m
+      msg = ("message %s" % m).encode('ascii')
       n = self.snd.send(msg)
       assert n == len(msg)
       assert self.snd.advance()
@@ -848,7 +862,7 @@ class TransferTest(Test):
     #submit some more deliveries
     for m in range(1450, 1500):
       sd = self.snd.delivery("tag%s" % m)
-      msg = "message %s" % m
+      msg = ("message %s" % m).encode('ascii')
       n = self.snd.send(msg)
       assert n == len(msg)
       assert self.snd.advance()
@@ -863,7 +877,7 @@ class TransferTest(Test):
       assert rd is not None, m
       assert rd.tag == ("tag%s" % m), (rd.tag, m)
       msg = self.rcv.recv(1024)
-      assert msg == ("message %s" % m), (msg, m)
+      assert msg == ("message %s" % m).encode('ascii'), (msg, m)
       rd.update(Delivery.ACCEPTED)
       rd.settle()
 
@@ -873,7 +887,7 @@ class TransferTest(Test):
 
     for x in range(10):
         self.snd.delivery("tag%d" % x)
-        msg = "this is a test"
+        msg = six.b("this is a test")
         n = self.snd.send(msg)
         assert n == len(msg)
         assert self.snd.advance()
@@ -915,7 +929,7 @@ class MaxFrameTransferTest(Test):
     parts = []
     for i in range(size):
       parts.append(str(i))
-    return "/".join(parts)[:size]
+    return "/".join(parts)[:size].encode("utf-8")
 
   def testMinFrame(self):
     """
@@ -940,11 +954,11 @@ class MaxFrameTransferTest(Test):
 
     self.pump()
 
-    bytes = self.rcv.recv(513)
-    assert bytes == msg
+    binary = self.rcv.recv(513)
+    assert binary == msg
 
-    bytes = self.rcv.recv(1024)
-    assert bytes == None
+    binary = self.rcv.recv(1024)
+    assert binary == None
 
   def testOddFrame(self):
     """
@@ -962,18 +976,18 @@ class MaxFrameTransferTest(Test):
 
     self.rcv.flow(2)
     self.snd.delivery("tag")
-    msg = "X" * 1699
+    msg = ("X" * 1699).encode('utf-8')
     n = self.snd.send(msg)
     assert n == len(msg)
     assert self.snd.advance()
 
     self.pump()
 
-    bytes = self.rcv.recv(1699)
-    assert bytes == msg
+    binary = self.rcv.recv(1699)
+    assert binary == msg
 
-    bytes = self.rcv.recv(1024)
-    assert bytes == None
+    binary = self.rcv.recv(1024)
+    assert binary == None
 
     self.rcv.advance()
 
@@ -985,13 +999,13 @@ class MaxFrameTransferTest(Test):
 
     self.pump()
 
-    bytes = self.rcv.recv(1426)
-    assert bytes == msg
+    binary = self.rcv.recv(1426)
+    assert binary == msg
 
     self.pump()
 
-    bytes = self.rcv.recv(1024)
-    assert bytes == None
+    binary = self.rcv.recv(1024)
+    assert binary == None
     
   def testBigMessage(self):
     """
@@ -1013,11 +1027,11 @@ class MaxFrameTransferTest(Test):
 
     self.pump()
 
-    bytes = self.rcv.recv(1024*256)
-    assert bytes == msg
+    binary = self.rcv.recv(1024*256)
+    assert binary == msg
 
-    bytes = self.rcv.recv(1024)
-    assert bytes == None
+    binary = self.rcv.recv(1024)
+    assert binary == None
 
 
 class IdleTimeoutTest(Test):
@@ -1389,7 +1403,7 @@ class CreditTest(Test):
 
     sd = self.snd.delivery("tagA")
     assert sd
-    n = self.snd.send("A")
+    n = self.snd.send(six.b("A"))
     assert n == 1
     self.pump()
     self.snd.advance()
@@ -1405,8 +1419,8 @@ class CreditTest(Test):
     assert self.snd.credit == 9, self.snd.credit
     assert self.rcv.credit == 10, self.rcv.credit
 
-    bytes = self.rcv.recv(10)
-    assert bytes == "A", bytes
+    data = self.rcv.recv(10)
+    assert data == six.b("A"), data
     self.rcv.advance()
     self.pump()
     assert self.snd.credit == 9, self.snd.credit
@@ -1427,7 +1441,7 @@ class CreditTest(Test):
 
     sd = self.snd.delivery("tagB")
     assert sd
-    n = self.snd.send("B")
+    n = self.snd.send(six.b("B"))
     assert n == 1
     self.snd.advance()
     self.pump()
@@ -1441,7 +1455,7 @@ class CreditTest(Test):
 
     sd = self.snd.delivery("tagC")
     assert sd
-    n = self.snd.send("C")
+    n = self.snd.send(six.b("C"))
     assert n == 1
     self.snd.advance()
     self.pump()
@@ -1455,11 +1469,11 @@ class CreditTest(Test):
     assert self.snd.credit == 0, self.snd.credit
     assert self.rcv.credit == 2, self.rcv.credit
 
-    bytes = self.rcv.recv(10)
-    assert bytes == "B", bytes
+    data = self.rcv.recv(10)
+    assert data == six.b("B"), data
     self.rcv.advance()
-    bytes = self.rcv.recv(10)
-    assert bytes == "C", bytes
+    data = self.rcv.recv(10)
+    assert data == six.b("C"), data
     self.rcv.advance()
     self.pump()
     assert self.snd.credit == 0, self.snd.credit
@@ -1512,10 +1526,10 @@ class CreditTest(Test):
       for i in range(10):
           tag = "test %d" % i
           self.snd.delivery( tag )
-          self.snd.send( tag )
+          self.snd.send( tag.encode("ascii") )
           assert self.snd.advance()
           self.snd2.delivery( tag )
-          self.snd2.send( tag )
+          self.snd2.send( tag.encode("ascii") )
           assert self.snd2.advance()
 
       self.pump()
@@ -1554,11 +1568,12 @@ class SessionCreditTest(Test):
     assert snd.queued == 0, snd.queued
     assert rcv.queued == 0, rcv.queued
 
+    data = bytes(bytearray(size))
     idx = 0
     while snd.credit:
       d = snd.delivery("tag%s" % idx)
       assert d
-      n = snd.send(chr(ord("a") + idx)*size)
+      n = snd.send(data)
       assert n == size, (n, size)
       assert snd.advance()
       self.pump()
@@ -1632,7 +1647,7 @@ class SessionCreditTest(Test):
     idx = 0
     while snd.credit:
       d = snd.delivery("tag%s" % idx)
-      snd.send("x"*1024)
+      snd.send(("x"*1024).encode('ascii'))
       assert d
       assert snd.advance()
       self.pump()
@@ -1735,7 +1750,7 @@ class SettlementTest(Test):
     for i in range(count):
       sd = self.snd.delivery("tag%s" % i)
       assert sd
-      n = self.snd.send("x"*size)
+      n = self.snd.send(("x"*size).encode('ascii'))
       assert n == size, n
       assert self.snd.advance()
       self.pump()
@@ -1793,7 +1808,7 @@ class PipelineTest(Test):
 
     for i in range(10):
       d = snd.delivery("delivery-%s" % i)
-      snd.send("delivery-%s" % i)
+      snd.send(six.b("delivery-%s" % i))
       d.settle()
 
     snd.close()
@@ -2225,7 +2240,7 @@ class EventTest(CollectorTest):
     self.expect(Event.CONNECTION_INIT, Event.SESSION_INIT,
                 Event.LINK_INIT, Event.LINK_LOCAL_OPEN, Event.TRANSPORT)
     snd.delivery("delivery")
-    snd.send("Hello World!")
+    snd.send(six.b("Hello World!"))
     snd.advance()
     self.pump()
     self.expect()
@@ -2241,7 +2256,7 @@ class EventTest(CollectorTest):
     snd, rcv = self.testFlowEvents()
     snd.open()
     dlv = snd.delivery("delivery")
-    snd.send("Hello World!")
+    snd.send(six.b("Hello World!"))
     assert snd.advance()
     self.expect(Event.LINK_LOCAL_OPEN, Event.TRANSPORT)
     self.pump()
@@ -2252,7 +2267,7 @@ class EventTest(CollectorTest):
     rdlv.update(Delivery.ACCEPTED)
     self.pump()
     event = self.expect(Event.DELIVERY)
-    assert event.context == dlv
+    assert event.context == dlv, (dlv, event.context)
 
   def testConnectionBOUND_UNBOUND(self):
     c = Connection()
@@ -2272,7 +2287,7 @@ class EventTest(CollectorTest):
     t.bind(c)
     self.expect(Event.CONNECTION_BOUND)
     assert t.condition is None
-    t.push("asdf")
+    t.push(six.b("asdf"))
     self.expect(Event.TRANSPORT_ERROR, Event.TRANSPORT_TAIL_CLOSED)
     assert t.condition is not None
     assert t.condition.name == "amqp:connection:framing-error"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/python/proton_tests/interop.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/interop.py b/tests/python/proton_tests/interop.py
index 1ef92dd..5cbab99 100644
--- a/tests/python/proton_tests/interop.py
+++ b/tests/python/proton_tests/interop.py
@@ -19,6 +19,7 @@
 
 from proton import *
 import os
+import six
 from . import common
 
 
@@ -71,7 +72,7 @@ class InteropTest(common.Test):
         self.decode_data(body)
 
     def assert_next(self, type, value):
-        next_type = next(self.data)
+        next_type = self.data.next()
         assert next_type == type, "Type mismatch: %s != %s"%(
             Data.type_names[next_type], Data.type_names[type])
         next_value = self.data.get_object()
@@ -80,7 +81,7 @@ class InteropTest(common.Test):
     def test_message(self):
         self.decode_message_file("message")
         self.assert_next(Data.STRING, "hello")
-        assert next(self.data) is None
+        assert self.data.next() is None
 
     def test_primitives(self):
         self.decode_data_file("primitives")
@@ -95,30 +96,30 @@ class InteropTest(common.Test):
         self.assert_next(Data.LONG, -12345)
         self.assert_next(Data.FLOAT, 0.125)
         self.assert_next(Data.DOUBLE, 0.125)
-        assert next(self.data) is None
+        assert self.data.next() is None
 
     def test_strings(self):
         self.decode_data_file("strings")
-        self.assert_next(Data.BINARY, "abc\0defg")
+        self.assert_next(Data.BINARY, six.b("abc\0defg"))
         self.assert_next(Data.STRING, "abcdefg")
         self.assert_next(Data.SYMBOL, "abcdefg")
-        self.assert_next(Data.BINARY, "")
+        self.assert_next(Data.BINARY, six.b(""))
         self.assert_next(Data.STRING, "")
         self.assert_next(Data.SYMBOL, "")
-        assert next(self.data) is None
+        assert self.data.next() is None
 
     def test_described(self):
         self.decode_data_file("described")
         self.assert_next(Data.DESCRIBED, Described("foo-descriptor", "foo-value"))
         self.data.exit()
 
-        assert next(self.data) == Data.DESCRIBED
+        assert self.data.next() == Data.DESCRIBED
         self.data.enter()
         self.assert_next(Data.INT, 12)
         self.assert_next(Data.INT, 13)
         self.data.exit()
 
-        assert next(self.data) is None
+        assert self.data.next() is None
 
     def test_described_array(self):
         self.decode_data_file("described_array")
@@ -129,17 +130,17 @@ class InteropTest(common.Test):
         self.assert_next(Data.ARRAY, Array(UNDESCRIBED, Data.INT, *range(0,100)))
         self.assert_next(Data.ARRAY, Array(UNDESCRIBED, Data.STRING, *["a", "b", "c"]))
         self.assert_next(Data.ARRAY, Array(UNDESCRIBED, Data.INT))
-        assert next(self.data) is None
+        assert self.data.next() is None
 
     def test_lists(self):
         self.decode_data_file("lists")
         self.assert_next(Data.LIST, [32, "foo", True])
         self.assert_next(Data.LIST, [])
-        assert next(self.data) is None
+        assert self.data.next() is None
 
     def test_maps(self):
         self.decode_data_file("maps")
         self.assert_next(Data.MAP, {"one":1, "two":2, "three":3 })
         self.assert_next(Data.MAP, {1:"one", 2:"two", 3:"three"})
         self.assert_next(Data.MAP, {})
-        assert next(self.data) is None
+        assert self.data.next() is None

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/python/proton_tests/message.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/message.py b/tests/python/proton_tests/message.py
index 3366366..10d2326 100644
--- a/tests/python/proton_tests/message.py
+++ b/tests/python/proton_tests/message.py
@@ -18,6 +18,7 @@
 #
 
 import os
+import six
 from . import common
 from proton import *
 try:
@@ -38,7 +39,7 @@ class AccessorsTest(Test):
 
   def _test(self, name, default, values):
     d = getattr(self.msg, name)
-    assert d == default, d
+    assert d == default, (d, default)
     for v in values:
       setattr(self.msg, name, v)
       gotten = getattr(self.msg, name)
@@ -72,7 +73,8 @@ class AccessorsTest(Test):
     self._test("delivery_count", 0, range(0, 1024))
 
   def testUserId(self):
-    self._test("user_id", "", ("asdf", "fdsa", "asd\x00fdsa", ""))
+    self._test("user_id", six.b(""), (six.b("asdf"), six.b("fdsa"),
+                                      six.b("asd\x00fdsa"), six.b("")))
 
   def testAddress(self):
     self._test_str("address")

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/python/proton_tests/messenger.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/messenger.py b/tests/python/proton_tests/messenger.py
index 03a1b6b..30d0ec5 100644
--- a/tests/python/proton_tests/messenger.py
+++ b/tests/python/proton_tests/messenger.py
@@ -19,6 +19,7 @@ from __future__ import absolute_import
 #
 
 import os, sys, traceback
+from six.moves import range as xrange
 from . import common
 from proton import *
 from threading import Thread, Event

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index 4d569bc..2734364 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -19,6 +19,7 @@ from __future__ import absolute_import
 #
 
 import sys, os
+import six
 from . import common
 from proton import *
 from .common import pump, Skipped
@@ -121,7 +122,7 @@ class SaslTest(Test):
     c1.open()
 
     # get all t1's output in one buffer then pass it all to t2
-    out1_sasl_and_amqp = ""
+    out1_sasl_and_amqp = six.b("")
     t1_still_producing = True
     while t1_still_producing:
       out1 = self.t1.peek(1024)
@@ -171,17 +172,17 @@ class SaslTest(Test):
 
     out = self.t1.peek(1024)
     self.t1.pop(len(out))
-    self.t1.push("AMQP\x03\x01\x00\x00")
+    self.t1.push(six.b("AMQP\x03\x01\x00\x00"))
     out = self.t1.peek(1024)
     self.t1.pop(len(out))
-    self.t1.push("\x00\x00\x00")
+    self.t1.push(six.b("\x00\x00\x00"))
     out = self.t1.peek(1024)
     self.t1.pop(len(out))
 
-    self.t1.push("6\x02\x01\x00\x00\x00S@\xc04\x01\xe01\x04\xa3\x05PLAIN\x0aDIGEST-MD5\x09ANONYMOUS\x08CRAM-MD5")
+    self.t1.push(six.b("6\x02\x01\x00\x00\x00S@\xc04\x01\xe01\x04\xa3\x05PLAIN\x0aDIGEST-MD5\x09ANONYMOUS\x08CRAM-MD5"))
     out = self.t1.peek(1024)
     self.t1.pop(len(out))
-    self.t1.push("\x00\x00\x00\x10\x02\x01\x00\x00\x00SD\xc0\x03\x01P\x00")
+    self.t1.push(six.b("\x00\x00\x00\x10\x02\x01\x00\x00\x00SD\xc0\x03\x01P\x00"))
     out = self.t1.peek(1024)
     self.t1.pop(len(out))
     while out:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/python/proton_tests/transport.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/transport.py b/tests/python/proton_tests/transport.py
index e158a5b..0b22f4e 100644
--- a/tests/python/proton_tests/transport.py
+++ b/tests/python/proton_tests/transport.py
@@ -18,6 +18,7 @@
 #
 
 import os
+import six
 from . import common
 from proton import *
 
@@ -44,9 +45,9 @@ class TransportTest(Test):
       if p < 0:
         return
       elif p > 0:
-        bytes = self.transport.peek(p)
-        self.peer.push(bytes)
-        self.transport.pop(len(bytes))
+        data = self.transport.peek(p)
+        self.peer.push(data)
+        self.transport.pop(len(data))
       else:
         assert False
 
@@ -61,16 +62,16 @@ class TransportTest(Test):
     assert self.conn.remote_condition.name == name, self.conn.remote_condition
 
   def testEOS(self):
-    self.transport.push("") # should be a noop
+    self.transport.push(six.b("")) # should be a noop
     self.transport.close_tail() # should result in framing error
     self.assert_error(u'amqp:connection:framing-error')
 
   def testPartial(self):
-    self.transport.push("AMQ") # partial header
+    self.transport.push(six.b("AMQ")) # partial header
     self.transport.close_tail() # should result in framing error
     self.assert_error(u'amqp:connection:framing-error')
 
-  def testGarbage(self, garbage="GARBAGE_"):
+  def testGarbage(self, garbage=six.b("GARBAGE_")):
     self.transport.push(garbage)
     self.assert_error(u'amqp:connection:framing-error')
     assert self.transport.pending() < 0
@@ -78,13 +79,13 @@ class TransportTest(Test):
     assert self.transport.pending() < 0
 
   def testSmallGarbage(self):
-    self.testGarbage("XXX")
+    self.testGarbage(six.b("XXX"))
 
   def testBigGarbage(self):
-    self.testGarbage("GARBAGE_XXX")
+    self.testGarbage(six.b("GARBAGE_XXX"))
 
   def testHeader(self):
-    self.transport.push("AMQP\x00\x01\x00\x00")
+    self.transport.push(six.b("AMQP\x00\x01\x00\x00"))
     self.transport.close_tail()
     self.assert_error(u'amqp:connection:framing-error')
 
@@ -102,8 +103,8 @@ class TransportTest(Test):
     trn = Transport()
     trn.bind(conn)
     out = trn.peek(1024)
-    assert "test-container" in out, repr(out)
-    assert "test-hostname" in out, repr(out)
+    assert six.b("test-container") in out, repr(out)
+    assert six.b("test-hostname") in out, repr(out)
     self.transport.push(out)
 
     c = Connection()
@@ -160,7 +161,7 @@ class TransportTest(Test):
     self.transport.pop(len(dat2) - len(dat1))
     dat3 = self.transport.peek(1024)
     self.transport.pop(len(dat3))
-    assert self.transport.peek(1024) == ""
+    assert self.transport.peek(1024) == six.b("")
 
     self.peer.push(dat1)
     self.peer.push(dat2[len(dat1):])

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/python/proton_tests/utils.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/utils.py b/tests/python/proton_tests/utils.py
index 727b586..86eb6f3 100644
--- a/tests/python/proton_tests/utils.py
+++ b/tests/python/proton_tests/utils.py
@@ -18,6 +18,7 @@
 #
 
 import os, time
+from six.moves import range as xrange
 from threading import Thread, Event
 from unittest import TestCase
 from proton_tests.common import Test, free_tcp_port

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/tools/apps/python/msgr-recv.py
----------------------------------------------------------------------
diff --git a/tests/tools/apps/python/msgr-recv.py b/tests/tools/apps/python/msgr-recv.py
index 079c871..757b19c 100755
--- a/tests/tools/apps/python/msgr-recv.py
+++ b/tests/tools/apps/python/msgr-recv.py
@@ -23,6 +23,11 @@ import sys, optparse, time
 import logging
 from proton import *
 
+# Hi python3!
+try:
+    long()
+except:
+    long = int
 
 
 usage = """

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/tools/apps/python/msgr-send.py
----------------------------------------------------------------------
diff --git a/tests/tools/apps/python/msgr-send.py b/tests/tools/apps/python/msgr-send.py
index a2f67c5..2e2583f 100755
--- a/tests/tools/apps/python/msgr-send.py
+++ b/tests/tools/apps/python/msgr-send.py
@@ -23,6 +23,11 @@ import sys, optparse, time
 import logging
 from proton import *
 
+# Hi python3!
+try:
+    long()
+except:
+    long = int
 
 
 usage = """

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99299d3b/tests/tools/soak-check
----------------------------------------------------------------------
diff --git a/tests/tools/soak-check b/tests/tools/soak-check
index 36d7984..bf5b147 100755
--- a/tests/tools/soak-check
+++ b/tests/tools/soak-check
@@ -17,13 +17,14 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from subprocess import Popen,PIPE
 
 def run_test(cmd):
     try:
         process = Popen(cmd)
-    except OSError, e:
+    except OSError:
         assert False, "Unable to execute command '%s', is it in your PATH?" % cmd[0]
     return process.wait()
 
@@ -121,7 +122,7 @@ def main(argv=None):
                 command.append( "-Dverbose" )
             command.append( pattern )
             if verbose:
-                print "command='%s'" % str(command)
+                print("command='%s'" % str(command))
             run_test(command)
     return 0
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[12/34] qpid-proton git commit: PROTON-490: avoid decoding text if method calls fail

Posted by kg...@apache.org.
PROTON-490: avoid decoding text if method calls fail


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

Branch: refs/heads/master
Commit: 9380ed938fafa9e19cb0d3514725427d8243041b
Parents: 99299d3
Author: Ken Giusti <kg...@apache.org>
Authored: Mon Apr 27 11:41:04 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Apr 27 11:41:04 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/cproton.i | 40 ++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9380ed93/proton-c/bindings/python/cproton.i
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/cproton.i b/proton-c/bindings/python/cproton.i
index 328d68a..7317ca1 100644
--- a/proton-c/bindings/python/cproton.i
+++ b/proton-c/bindings/python/cproton.i
@@ -34,7 +34,6 @@
 
 %include <cstring.i>
 
-%cstring_output_withsize(char *OUTPUT, size_t *OUTPUT_SIZE)
 %cstring_output_allocate_size(char **ALLOC_OUTPUT, size_t *ALLOC_SIZE, free(*$1));
 %cstring_output_maxsize(char *OUTPUT, size_t MAX_OUTPUT_SIZE)
 
@@ -61,6 +60,27 @@
   %append_output(PyBytes_FromStringAndSize($1,*$2));
 }
 
+// Typemap for those methods that return variable length text data in a buffer
+// provided as a parameter.  If the method fails we must avoid attempting to
+// decode the contents of the buffer as it does not carry valid text data.
+%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (char *VTEXT_OUT, size_t *VTEXT_SIZE)
+(int res, size_t n, char *buff = 0, $*2_ltype size) {
+  res = SWIG_AsVal(size_t)($input, &n);
+  if (!SWIG_IsOK(res)) {
+    %argument_fail(res, "(char *VTEXT_OUT, size_t *VTEXT_SIZE)", $symname, $argnum);
+  }
+  buff = %new_array(n+1, char);
+  $1 = %static_cast(buff, $1_ltype);
+  size = %numeric_cast(n,$*2_ltype);
+  $2 = &size;
+}
+%typemap(freearg,noblock=1,match="in")(char *VTEXT_OUT, size_t *VTEXT_SIZE) {
+  if (buff$argnum) %delete_array(buff$argnum);
+}
+%typemap(argout,noblock=1,fragment="SWIG_FromCharPtrAndSize") (char *VTEXT_OUT, size_t *VTEXT_SIZE) {
+  %append_output(SWIG_FromCharPtrAndSize($1,*$2));
+}
+
 
 // These are not used/needed in the python binding
 %ignore pn_message_get_id;
@@ -186,7 +206,14 @@ ssize_t pn_data_decode(pn_data_t *data, const char *BIN_IN, size_t BIN_LEN);
 %}
 %ignore pn_data_encode;
 
-int pn_data_format(pn_data_t *data, char *OUTPUT, size_t *OUTPUT_SIZE);
+%rename(pn_data_format) wrap_pn_data_format;
+%inline %{
+  int wrap_pn_data_format(pn_data_t *data, char *VTEXT_OUT, size_t *VTEXT_SIZE) {
+    int err = pn_data_format(data, VTEXT_OUT, VTEXT_SIZE);
+    if (err) *VTEXT_SIZE = 0;
+    return err;
+  }
+%}
 %ignore pn_data_format;
 
 bool pn_ssl_get_cipher_name(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_SIZE);
@@ -195,7 +222,14 @@ bool pn_ssl_get_cipher_name(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_SIZE)
 bool pn_ssl_get_protocol_name(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_SIZE);
 %ignore pn_ssl_get_protocol_name;
 
-int pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE);
+%rename(pn_ssl_get_peer_hostname) wrap_pn_ssl_get_peer_hostname;
+%inline %{
+  int wrap_pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *VTEXT_OUT, size_t *VTEXT_SIZE) {
+    int err = pn_ssl_get_peer_hostname(ssl, VTEXT_OUT, VTEXT_SIZE);
+    if (err) *VTEXT_SIZE = 0;
+    return err;
+  }
+%}
 %ignore pn_ssl_get_peer_hostname;
 
 %immutable PN_PYREF;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[25/34] qpid-proton git commit: PROTON-490: Add py27 to tox and fix the sdist step

Posted by kg...@apache.org.
PROTON-490: Add py27 to tox and fix the sdist step

(cherry picked from commit e5a8b0418ac15d42e0950f6f14c599a62524db14)


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

Branch: refs/heads/master
Commit: d09e93e56c56619242d6a4d92107036b9f3fee67
Parents: ce45c3a
Author: Flavio Percoco <fl...@gmail.com>
Authored: Wed Jun 17 16:05:28 2015 +0200
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Jun 17 11:27:32 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/setup.py | 20 +++++++++++++++-----
 proton-c/bindings/python/tox.ini  | 25 +++++++++----------------
 2 files changed, 24 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d09e93e5/proton-c/bindings/python/setup.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setup.py b/proton-c/bindings/python/setup.py
index e6fbb79..1738a14 100755
--- a/proton-c/bindings/python/setup.py
+++ b/proton-c/bindings/python/setup.py
@@ -98,6 +98,7 @@ class Configure(build_ext):
             return compiler.compiler_type
 
     def bundle_libqpid_proton_extension(self):
+        setup_path = os.path.dirname(os.path.realpath(__file__))
         base = self.get_finalized_command('build').build_base
         build_include = os.path.join(base, 'include')
         install = self.get_finalized_command('install').install_base
@@ -107,11 +108,20 @@ class Configure(build_ext):
         log.info("Using bundled libqpid-proton")
 
         if 'QPID_PROTON_SRC' not in os.environ:
-            bundledir = os.path.join(base, "bundled")
-            if not os.path.exists(bundledir):
-                os.makedirs(bundledir)
-            bundle.fetch_libqpid_proton(bundledir)
-            libqpid_proton_dir = os.path.abspath(os.path.join(bundledir, 'qpid-proton'))
+            if not os.path.exists(os.path.join(setup_path, 'tox.ini')):
+                bundledir = os.path.join(base, "bundled")
+                if not os.path.exists(bundledir):
+                    os.makedirs(bundledir)
+                bundle.fetch_libqpid_proton(bundledir)
+                libqpid_proton_dir = os.path.abspath(os.path.join(bundledir, 'qpid-proton'))
+            else:
+                # This should happen just in **dev** environemnts since
+                # tox.ini is not shipped with the driver. It should only
+                # be triggered when calling `setup.py`. This can happen either
+                # manually or when calling `tox` in the **sdist** step. Tox will
+                # defined the `QPID_PROTON_SRC` itself.
+                proton_c = os.path.join(setup_path, '..', '..', '..')
+                libqpid_proton_dir = os.path.abspath(proton_c)
         else:
             libqpid_proton_dir = os.path.abspath(os.environ['QPID_PROTON_SRC'])
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d09e93e5/proton-c/bindings/python/tox.ini
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/tox.ini b/proton-c/bindings/python/tox.ini
index b2277da..acfa5a1 100644
--- a/proton-c/bindings/python/tox.ini
+++ b/proton-c/bindings/python/tox.ini
@@ -1,13 +1,16 @@
 [tox]
-envlist = build,py34
+envlist = py27,py34
 minversion = 1.4
 skipdist = True
 
 [testenv]
 usedevelop = False
-changedir = {toxinidir}/../../proton-c/include/
+#changedir = {toxinidir}/../../proton-c/include/
 setenv =
     VIRTUAL_ENV={envdir}
+    PKG_CONFIG_PATH=None
+    QPID_PROTON_SRC={toxinidir}/../../../
+    DEBUG=True
 passenv =
     PKG_CONFIG_PATH
     CFLAGS
@@ -20,18 +23,8 @@ commands = flake8
 [testenv:docs]
 commands = python setup.py build_sphinx
 
-[testenv:py34]
-platform = linux
-setenv =
-    VIRTUAL_ENV={envdir}
-    PKG_CONFIG_PATH=None
-    QPID_PROTON_SRC={toxinidir}/../../../
-    DEBUG=True
+[testenv:py27]
+platform = linux|linux2
 
-[testenv:build]
-platform = linux2
-setenv =
-    VIRTUAL_ENV={envdir}
-    PKG_CONFIG_PATH=None
-    QPID_PROTON_SRC={toxinidir}/../../../
-    DEBUG=True
\ No newline at end of file
+[testenv:py34]
+platform = linux|linux2
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[31/34] qpid-proton git commit: PROTON-490: Support for py26

Posted by kg...@apache.org.
PROTON-490: Support for py26

(cherry picked from commit c5b7f543a52f4d1f0fbe384b6244528f5ee38266)


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

Branch: refs/heads/master
Commit: cb59c19abce5e3fa3879d54bff4ecb2e9bc0f136
Parents: 1354648
Author: Flavio Percoco <fl...@gmail.com>
Authored: Thu Jun 18 15:52:40 2015 +0200
Committer: Ken Giusti <kg...@apache.org>
Committed: Thu Jun 18 14:01:04 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/setup.py | 7 ++++---
 proton-c/bindings/python/tox.ini  | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cb59c19a/proton-c/bindings/python/setup.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setup.py b/proton-c/bindings/python/setup.py
index 4cdd721..1eb3e64 100755
--- a/proton-c/bindings/python/setup.py
+++ b/proton-c/bindings/python/setup.py
@@ -315,7 +315,7 @@ class Configure(build_ext):
 
         _cproton.runtime_library_dirs.extend([install_lib])
 
-        if sys.version_info.major >= 3:
+        if sys.version_info[0] >= 3:
             _cproton.libraries[0] = "qpid-proton%s" % ds_sys.get_config_var('EXT_SUFFIX')[:-3]
 
         # Register this new extension and make
@@ -335,8 +335,9 @@ class Configure(build_ext):
         return not self.check_qpid_proton_version()
 
     def run(self):
-        # linux2 for python<3.0
-        if sys.platform in ['linux', 'linux2']:
+        # linux2 for python<2.7
+        # linux4 for python<2.6
+        if sys.platform in ['linux', 'linux2', 'linux4']:
             if self.bundle_proton:
                 self.bundle_libqpid_proton_extension()
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cb59c19a/proton-c/bindings/python/tox.ini
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/tox.ini b/proton-c/bindings/python/tox.ini
index 8a8c87c..2bb26a6 100644
--- a/proton-c/bindings/python/tox.ini
+++ b/proton-c/bindings/python/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py27,py33,py34
+envlist = py26,py27,py33,py34
 minversion = 1.4
 skipdist = True
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[17/34] qpid-proton git commit: PROTON-490: fix long/int conversion mixup

Posted by kg...@apache.org.
PROTON-490: fix long/int conversion mixup


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

Branch: refs/heads/master
Commit: 64a7ce2964da2832a8e2248c07aac4a60dc9b7cd
Parents: 9e7f16c
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Apr 29 15:19:05 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Apr 29 15:19:05 2015 -0400

----------------------------------------------------------------------
 examples/python/test_examples.py            |  8 +++-----
 proton-c/bindings/python/proton/__init__.py | 13 +++++++------
 2 files changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/64a7ce29/examples/python/test_examples.py
----------------------------------------------------------------------
diff --git a/examples/python/test_examples.py b/examples/python/test_examples.py
index 6a411d3..7f87616 100644
--- a/examples/python/test_examples.py
+++ b/examples/python/test_examples.py
@@ -24,10 +24,8 @@ import unittest
 
 if sys.version_info[0] == 2:
     _unicode_prefix = 'u'
-    _long_suffix = 'L'
 else:
     _unicode_prefix = ''
-    _long_suffix = ''
 
 
 class ExamplesTest(unittest.TestCase):
@@ -58,7 +56,7 @@ class ExamplesTest(unittest.TestCase):
         s.wait()
         r.wait()
         actual = [l.strip() for l in r.stdout]
-        expected = ["{'sequence': %i%s}" % ((i+1), _long_suffix) for i in range(100)]
+        expected = ["{'sequence': %i}" % (i+1) for i in range(100)]
         self.assertEqual(actual, expected)
 
     def test_client_server(self, client=['client.py'], server=['server.py'], sleep=0):
@@ -137,7 +135,7 @@ class ExamplesTest(unittest.TestCase):
         s.wait()
         r.wait()
         actual = [l.strip() for l in r.stdout]
-        expected = ["{'sequence': %i%s}" % ((i+1), _long_suffix) for i in range(100)]
+        expected = ["{'sequence': %i}" % (i+1) for i in range(100)]
         self.assertEqual(actual, expected)
 
     def test_direct_send_simple_recv(self):
@@ -149,5 +147,5 @@ class ExamplesTest(unittest.TestCase):
         r.wait()
         s.wait()
         actual = [l.strip() for l in r.stdout]
-        expected = ["{'sequence': %i%s}" % ((i+1), _long_suffix) for i in range(100)]
+        expected = ["{'sequence': %i}" % (i+1) for i in range(100)]
         self.assertEqual(actual, expected)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/64a7ce29/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
index 864b25e..8b9ffeb 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -1934,7 +1934,7 @@ class Data:
     If the current node is a signed int, returns its value, returns 0
     otherwise.
     """
-    return pn_data_get_int(self._data)
+    return int(pn_data_get_int(self._data))
 
   def get_char(self):
     """
@@ -1955,7 +1955,7 @@ class Data:
     If the current node is an signed long, returns its value, returns
     0 otherwise.
     """
-    return pn_data_get_long(self._data)
+    return long(pn_data_get_long(self._data))
 
   def get_timestamp(self):
     """
@@ -2158,7 +2158,7 @@ class Data:
     unicode: put_string,
     bytes: put_binary,
     symbol: put_symbol,
-    int: put_long,
+    long: put_long,
     char: put_char,
     ulong: put_ulong,
     timestamp: put_timestamp,
@@ -2167,9 +2167,10 @@ class Data:
     Described: put_py_described,
     Array: put_py_array
     }
-  # for python 2.x:
-  if long not in put_mappings:
-      put_mappings[long] = put_long
+  # for python 3.x, long is merely an alias for int, but for python 2.x
+  # we need to add an explicit int since it is a different type
+  if int not in put_mappings:
+      put_mappings[int] = put_int
 
   get_mappings = {
     NULL: lambda s: None,


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[32/34] qpid-proton git commit: PROTON-490: transport I/O is binary, not str

Posted by kg...@apache.org.
PROTON-490: transport I/O is binary, not str


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

Branch: refs/heads/master
Commit: 35eb6bb3332c8965f4fe1434c30517238a52a0bb
Parents: cb59c19
Author: Ken Giusti <kg...@apache.org>
Authored: Thu Jun 18 16:09:05 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Thu Jun 18 16:09:05 2015 -0400

----------------------------------------------------------------------
 tests/python/proton_tests/transport.py | 32 +++++++++++++++--------------
 1 file changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/35eb6bb3/tests/python/proton_tests/transport.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/transport.py b/tests/python/proton_tests/transport.py
index dd02c81..07268e1 100644
--- a/tests/python/proton_tests/transport.py
+++ b/tests/python/proton_tests/transport.py
@@ -90,11 +90,11 @@ class ClientTransportTest(Test):
     self.assert_error(u'amqp:connection:framing-error')
 
   def testProtocolNotSupported(self):
-    self.transport.push("AMQP\x01\x01\x0a\x00")
+    self.transport.push(str2bin("AMQP\x01\x01\x0a\x00"))
     p = self.transport.pending()
     assert p >= 8, p
     bytes = self.transport.peek(p)
-    assert bytes[:8] == "AMQP\x00\x01\x00\x00"
+    assert bytes[:8] == str2bin("AMQP\x00\x01\x00\x00")
     self.transport.pop(p)
     self.drain()
     assert self.transport.closed
@@ -214,29 +214,29 @@ class ServerTransportTest(Test):
 
   # TODO: This may no longer be testing anything
   def testEOS(self):
-    self.transport.push("") # should be a noop
+    self.transport.push(str2bin("")) # should be a noop
     self.transport.close_tail()
     p = self.transport.pending()
     self.drain()
     assert self.transport.closed
 
   def testPartial(self):
-    self.transport.push("AMQ") # partial header
+    self.transport.push(str2bin("AMQ")) # partial header
     self.transport.close_tail()
     p = self.transport.pending()
     assert p >= 8, p
     bytes = self.transport.peek(p)
-    assert bytes[:8] == "AMQP\x00\x01\x00\x00"
+    assert bytes[:8] == str2bin("AMQP\x00\x01\x00\x00")
     self.transport.pop(p)
     self.drain()
     assert self.transport.closed
 
   def testGarbage(self, garbage="GARBAGE_"):
-    self.transport.push(garbage)
+    self.transport.push(str2bin(garbage))
     p = self.transport.pending()
     assert p >= 8, p
     bytes = self.transport.peek(p)
-    assert bytes[:8] == "AMQP\x00\x01\x00\x00"
+    assert bytes[:8] == str2bin("AMQP\x00\x01\x00\x00")
     self.transport.pop(p)
     self.drain()
     assert self.transport.closed
@@ -248,16 +248,16 @@ class ServerTransportTest(Test):
     self.testGarbage("GARBAGE_XXX")
 
   def testHeader(self):
-    self.transport.push("AMQP\x00\x01\x00\x00")
+    self.transport.push(str2bin("AMQP\x00\x01\x00\x00"))
     self.transport.close_tail()
     self.assert_error(u'amqp:connection:framing-error')
 
   def testProtocolNotSupported(self):
-    self.transport.push("AMQP\x01\x01\x0a\x00")
+    self.transport.push(str2bin("AMQP\x01\x01\x0a\x00"))
     p = self.transport.pending()
     assert p >= 8, p
     bytes = self.transport.peek(p)
-    assert bytes[:8] == "AMQP\x00\x01\x00\x00"
+    assert bytes[:8] == str2bin("AMQP\x00\x01\x00\x00")
     self.transport.pop(p)
     self.drain()
     assert self.transport.closed
@@ -276,8 +276,8 @@ class ServerTransportTest(Test):
     trn = Transport()
     trn.bind(conn)
     out = trn.peek(1024)
-    assert "test-container" in out, repr(out)
-    assert "test-hostname" in out, repr(out)
+    assert str2bin("test-container") in out, repr(out)
+    assert str2bin("test-hostname") in out, repr(out)
     self.transport.push(out)
 
     c = Connection()
@@ -294,7 +294,8 @@ class ServerTransportTest(Test):
     assert n >= 0, n
     try:
       self.transport.close_head()
-    except TransportException, e:
+    except TransportException:
+      e = sys.exc_info()[1]
       assert "aborted" in str(e), str(e)
     n = self.transport.pending()
     assert n < 0, n
@@ -304,7 +305,8 @@ class ServerTransportTest(Test):
     assert n > 0, n
     try:
       self.transport.close_tail()
-    except TransportException, e:
+    except TransportException:
+      e = sys.exc_info()[1]
       assert "aborted" in str(e), str(e)
     n = self.transport.capacity()
     assert n < 0, n
@@ -332,7 +334,7 @@ class ServerTransportTest(Test):
     self.transport.pop(len(dat2) - len(dat1))
     dat3 = self.transport.peek(1024)
     self.transport.pop(len(dat3))
-    assert self.transport.peek(1024) == ""
+    assert self.transport.peek(1024) == str2bin("")
 
     self.peer.push(dat1)
     self.peer.push(dat2[len(dat1):])


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[16/34] qpid-proton git commit: PROTON-490: fix examples, reactor

Posted by kg...@apache.org.
PROTON-490: fix examples, reactor


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

Branch: refs/heads/master
Commit: 9e7f16ccb5b2240c218af5ace2c4a61f07af1b9c
Parents: 646ee41
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Apr 29 11:39:11 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Apr 29 12:49:55 2015 -0400

----------------------------------------------------------------------
 examples/python/test_examples.py           | 57 +++++++++++++++++--------
 proton-c/bindings/python/proton/reactor.py |  2 +-
 2 files changed, 41 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9e7f16cc/examples/python/test_examples.py
----------------------------------------------------------------------
diff --git a/examples/python/test_examples.py b/examples/python/test_examples.py
index 9c89344..6a411d3 100644
--- a/examples/python/test_examples.py
+++ b/examples/python/test_examples.py
@@ -17,13 +17,23 @@
 # under the License.
 #
 
+import sys
 import subprocess
 import time
 import unittest
 
+if sys.version_info[0] == 2:
+    _unicode_prefix = 'u'
+    _long_suffix = 'L'
+else:
+    _unicode_prefix = ''
+    _long_suffix = ''
+
+
 class ExamplesTest(unittest.TestCase):
     def test_helloworld(self, example="helloworld.py"):
-        p = subprocess.Popen([example], stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        p = subprocess.Popen([example], stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                             universal_newlines=True)
         p.wait()
         output = [l.strip() for l in p.stdout]
         self.assertEqual(output, ['Hello World!'])
@@ -41,19 +51,23 @@ class ExamplesTest(unittest.TestCase):
         self.test_helloworld('helloworld_direct_tornado.py')
 
     def test_simple_send_recv(self, recv='simple_recv.py', send='simple_send.py'):
-        r = subprocess.Popen([recv], stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
-        s = subprocess.Popen([send], stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        r = subprocess.Popen([recv], stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                             universal_newlines=True)
+        s = subprocess.Popen([send], stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                             universal_newlines=True)
         s.wait()
         r.wait()
         actual = [l.strip() for l in r.stdout]
-        expected = ["{'sequence': %iL}" % (i+1) for i in range(100)]
+        expected = ["{'sequence': %i%s}" % ((i+1), _long_suffix) for i in range(100)]
         self.assertEqual(actual, expected)
 
     def test_client_server(self, client=['client.py'], server=['server.py'], sleep=0):
-        s = subprocess.Popen(server, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        s = subprocess.Popen(server, stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                             universal_newlines=True)
         if sleep:
             time.sleep(sleep)
-        c = subprocess.Popen(client, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        c = subprocess.Popen(client, stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                             universal_newlines=True)
         c.wait()
         s.terminate()
         actual = [l.strip() for l in c.stdout]
@@ -84,14 +98,18 @@ class ExamplesTest(unittest.TestCase):
         # setup databases
         subprocess.check_call(['db_ctrl.py', 'init', './src_db'])
         subprocess.check_call(['db_ctrl.py', 'init', './dst_db'])
-        fill = subprocess.Popen(['db_ctrl.py', 'insert', './src_db'], stdin=subprocess.PIPE, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        fill = subprocess.Popen(['db_ctrl.py', 'insert', './src_db'],
+                                stdin=subprocess.PIPE, stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                                universal_newlines=True)
         for i in range(100):
             fill.stdin.write("Message-%i\n" % (i+1))
         fill.stdin.close()
         fill.wait()
         # run send and recv
-        r = subprocess.Popen(['db_recv.py', '-m', '100'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
-        s = subprocess.Popen(['db_send.py', '-m', '100'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        r = subprocess.Popen(['db_recv.py', '-m', '100'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                             universal_newlines=True)
+        s = subprocess.Popen(['db_send.py', '-m', '100'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                             universal_newlines=True)
         s.wait()
         r.wait()
         # verify output of receive
@@ -99,9 +117,10 @@ class ExamplesTest(unittest.TestCase):
         expected = ["inserted message %i" % (i+1) for i in range(100)]
         self.assertEqual(actual, expected)
         # verify state of databases
-        v = subprocess.Popen(['db_ctrl.py', 'list', './dst_db'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        v = subprocess.Popen(['db_ctrl.py', 'list', './dst_db'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                             universal_newlines=True)
         v.wait()
-        expected = ["(%i, u'Message-%i')" % ((i+1), (i+1)) for i in range(100)]
+        expected = ["(%i, %s'Message-%i')" % ((i+1), _unicode_prefix, (i+1)) for i in range(100)]
         actual = [l.strip() for l in v.stdout]
         self.assertEqual(actual, expected)
 
@@ -110,21 +129,25 @@ class ExamplesTest(unittest.TestCase):
 
     def test_simple_send_direct_recv(self):
         self.maxDiff = None
-        r = subprocess.Popen(['direct_recv.py', '-a', 'localhost:8888'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        r = subprocess.Popen(['direct_recv.py', '-a', 'localhost:8888'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                             universal_newlines=True)
         time.sleep(0.5)
-        s = subprocess.Popen(['simple_send.py', '-a', 'localhost:8888'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        s = subprocess.Popen(['simple_send.py', '-a', 'localhost:8888'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                             universal_newlines=True)
         s.wait()
         r.wait()
         actual = [l.strip() for l in r.stdout]
-        expected = ["{'sequence': %iL}" % (i+1) for i in range(100)]
+        expected = ["{'sequence': %i%s}" % ((i+1), _long_suffix) for i in range(100)]
         self.assertEqual(actual, expected)
 
     def test_direct_send_simple_recv(self):
-        s = subprocess.Popen(['direct_send.py', '-a', 'localhost:8888'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        s = subprocess.Popen(['direct_send.py', '-a', 'localhost:8888'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                             universal_newlines=True)
         time.sleep(0.5)
-        r = subprocess.Popen(['simple_recv.py', '-a', 'localhost:8888'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        r = subprocess.Popen(['simple_recv.py', '-a', 'localhost:8888'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
+                             universal_newlines=True)
         r.wait()
         s.wait()
         actual = [l.strip() for l in r.stdout]
-        expected = ["{'sequence': %iL}" % (i+1) for i in range(100)]
+        expected = ["{'sequence': %i%s}" % ((i+1), _long_suffix) for i in range(100)]
         self.assertEqual(actual, expected)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9e7f16cc/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index 2260375..b475333 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -224,7 +224,7 @@ class EventInjector(object):
         then this will be removed from the set of interest.
         """
         self._closed = True
-        os.write(self.pipe[1], "!")
+        os.write(self.pipe[1], _compat.str2bin("!"))
 
     def fileno(self):
         return self.pipe[0]


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[24/34] qpid-proton git commit: PROTON-490: fix some py34 incompatibilities

Posted by kg...@apache.org.
PROTON-490: fix some py34 incompatibilities


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

Branch: refs/heads/master
Commit: ce45c3a4bfc4174258ae0c681c883fb27e43404a
Parents: fc3f4f5
Author: Flavio Percoco <fl...@gmail.com>
Authored: Sun Jun 14 00:39:41 2015 +0200
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Jun 15 13:37:25 2015 -0400

----------------------------------------------------------------------
 tests/python/proton_tests/engine.py | 16 ++++++++--------
 tests/python/proton_tests/sasl.py   |  2 --
 2 files changed, 8 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ce45c3a4/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index 143e7d5..fcc648e 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -2533,10 +2533,10 @@ class SaslEventTest(CollectorTest):
     s.allowed_mechs("ANONYMOUS PLAIN")
     transport.bind(conn)
     self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND)
-    transport.push('AMQP\x03\x01\x00\x00\x00\x00\x00\x1c\x02\x01\x00\x00\x00S@'
-                   '\xc0\x0f\x01\xe0\x0c\x01\xa3\tANONYMOUS\x00\x00\x00\x10'
-                   '\x02\x01\x00\x00\x00SD\xc0\x03\x01P\x00AMQP\x00\x01\x00'
-                   '\x00')
+    transport.push(str2bin('AMQP\x03\x01\x00\x00\x00\x00\x00\x1c\x02\x01\x00\x00\x00S@'
+                           '\xc0\x0f\x01\xe0\x0c\x01\xa3\tANONYMOUS\x00\x00\x00\x10'
+                           '\x02\x01\x00\x00\x00SD\xc0\x03\x01P\x00AMQP\x00\x01\x00'
+                           '\x00'))
     self.expect(Event.TRANSPORT)
     p = transport.pending()
     bytes = transport.peek(p)
@@ -2559,10 +2559,10 @@ class SaslEventTest(CollectorTest):
     bytes = transport.peek(p)
     transport.pop(p)
     self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND, Event.TRANSPORT)
-    transport.push('AMQP\x03\x01\x00\x00\x00\x00\x00\x1c\x02\x01\x00\x00\x00S@'
-                   '\xc0\x0f\x01\xe0\x0c\x01\xa3\tANONYMOUS\x00\x00\x00\x10'
-                   '\x02\x01\x00\x00\x00SD\xc0\x03\x01P\x00AMQP\x00\x01\x00'
-                   '\x00')
+    transport.push(str2bin('AMQP\x03\x01\x00\x00\x00\x00\x00\x1c\x02\x01\x00\x00\x00S@'
+                           '\xc0\x0f\x01\xe0\x0c\x01\xa3\tANONYMOUS\x00\x00\x00\x10'
+                           '\x02\x01\x00\x00\x00SD\xc0\x03\x01P\x00AMQP\x00\x01\x00'
+                           '\x00'))
     self.expect(Event.TRANSPORT)
     p = transport.pending()
     bytes = transport.peek(p)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ce45c3a4/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index b214b62..b4e9c7a 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -27,8 +27,6 @@ from proton import *
 from .common import pump, Skipped
 from proton._compat import str2bin
 
-from cproton import *
-
 def _sslCertpath(file):
     """ Return the full path to the certificate,keyfile, etc.
     """


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[20/34] qpid-proton git commit: PROTON-490: convert string data to binary for transport push

Posted by kg...@apache.org.
PROTON-490: convert string data to binary for transport push


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

Branch: refs/heads/master
Commit: e7eb0c579b376e4f91667c4651f5a7fc84a053b2
Parents: 45238b4
Author: Ken Giusti <kg...@apache.org>
Authored: Fri May 1 13:07:08 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Fri May 1 13:07:08 2015 -0400

----------------------------------------------------------------------
 tests/python/proton_tests/engine.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e7eb0c57/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index bd0c212..c75bef9 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -2494,9 +2494,9 @@ class SaslEventTest(CollectorTest):
     transport.bind(conn)
     self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND)
 
-    transport.push('AMQP\x03\x01\x00\x00\x00\x00\x00 \x02\x01\x00\x00\x00SA'
-                   '\xd0\x00\x00\x00\x10\x00\x00\x00\x02\xa3\tANONYMOUS@'
-                   'AMQP\x00\x01\x00\x00')
+    transport.push(str2bin('AMQP\x03\x01\x00\x00\x00\x00\x00 \x02\x01\x00\x00\x00SA'
+                           '\xd0\x00\x00\x00\x10\x00\x00\x00\x02\xa3\tANONYMOUS@'
+                           'AMQP\x00\x01\x00\x00'))
     self.expect(Event.TRANSPORT)
     for i in range(1024):
       p = transport.pending()


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[21/34] qpid-proton git commit: Merge branch 'master' into kgiusti-python3

Posted by kg...@apache.org.
Merge branch 'master' into kgiusti-python3

Conflicts:
	tests/python/proton_tests/engine.py


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

Branch: refs/heads/master
Commit: 43a61bb0c051a15b19a5c7ca92bc873ea3e5ebfc
Parents: e7eb0c5 9272dea
Author: Ken Giusti <kg...@apache.org>
Authored: Tue May 5 09:43:12 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Tue May 5 09:43:12 2015 -0400

----------------------------------------------------------------------
 CMakeLists.txt                                  |  68 +++++----
 bin/release.sh                                  |  15 +-
 bin/version.sh                                  |   4 +-
 contrib/proton-hawtdispatch/pom.xml             |   2 +-
 contrib/proton-jms/pom.xml                      |   2 +-
 examples/java/messenger/pom.xml                 |   2 +-
 examples/python/README                          |   6 +-
 pom.xml                                         |   2 +-
 proton-c/CMakeLists.txt                         | 100 ++++++-------
 proton-c/bindings/python/proton/__init__.py     |   2 +-
 .../bindings/ruby/lib/qpid_proton/mapping.rb    |   4 +-
 proton-c/include/proton/delivery.h              |  11 +-
 proton-c/include/proton/version.h.in            |   1 +
 proton-c/src/engine/engine.c                    |  10 +-
 proton-c/src/object/map.c                       |  62 ++++++++-
 proton-c/src/tests/object.c                     | 139 +++++++++++++++++++
 proton-j/pom.xml                                |   2 +-
 tests/pom.xml                                   |   2 +-
 tests/python/proton_tests/engine.py             |  25 +++-
 version.txt                                     |   2 +-
 20 files changed, 346 insertions(+), 115 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/43a61bb0/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/43a61bb0/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --cc tests/python/proton_tests/engine.py
index c75bef9,05c8e19..06ea3f9
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@@ -16,16 -16,15 +16,18 @@@
  # specific language governing permissions and limitations
  # under the License.
  #
 +from __future__ import absolute_import
  
 -import os, common, gc
 +import os, gc
+ import sys
 +from . import common
  from time import time, sleep
  from proton import *
- from .common import pump
 -from common import pump, Skipped
++from .common import pump, Skipped
  from proton.reactor import Reactor
 +from proton._compat import str2bin
  
+ 
  # older versions of gc do not provide the garbage list
  if not hasattr(gc, "garbage"):
    gc.garbage=[]


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[13/34] qpid-proton git commit: Merge branch 'master' into kgiusti-python3

Posted by kg...@apache.org.
Merge branch 'master' into kgiusti-python3


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

Branch: refs/heads/master
Commit: 64cb4faf80e5244bde672c54f3372ae2d18dfa11
Parents: 9380ed9 f05810e
Author: Ken Giusti <kg...@apache.org>
Authored: Mon Apr 27 15:34:13 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Apr 27 15:34:13 2015 -0400

----------------------------------------------------------------------
 .travis.yml                                     |   6 +
 CMakeLists.txt                                  |   2 +-
 DEVELOPERS                                      |  36 ---
 DEVELOPERS.md                                   |  86 ++++++
 INSTALL.md                                      | 168 ++++++++++++
 README                                          | 259 -------------------
 README.md                                       |  40 +++
 bin/jenkins-proton-c-build.sh                   |  46 ++++
 jenkins-proton-c-build.sh                       |  41 ---
 proton-c/include/proton/condition.h             |   1 -
 proton-c/include/proton/connection.h            |   1 -
 proton-c/include/proton/delivery.h              |   1 -
 proton-c/include/proton/disposition.h           |   1 -
 proton-c/include/proton/event.h                 |   1 -
 proton-c/include/proton/io.h                    |   2 +-
 proton-c/include/proton/link.h                  |   1 -
 proton-c/include/proton/message.h               |   1 -
 proton-c/include/proton/sasl.h                  |   8 +-
 proton-c/include/proton/scanner.h               |   2 +-
 proton-c/include/proton/session.h               |   1 -
 proton-c/include/proton/ssl.h                   |   1 -
 proton-c/include/proton/terminus.h              |   1 -
 proton-c/include/proton/transport.h             |   1 -
 proton-c/include/proton/type_compat.h           |  11 +-
 proton-c/include/proton/types.h                 |   3 +-
 proton-c/src/dispatcher/dispatcher.h            |   1 -
 proton-c/src/framing/framing.h                  |   1 -
 proton-c/src/sasl/cyrus_sasl.c                  |   9 +
 proton-c/src/transport/transport.c              |   5 +
 proton-c/src/util.c                             |   1 -
 proton-c/src/util.h                             |   1 -
 .../qpid/proton/engine/impl/SessionImpl.java    |  51 +++-
 .../qpid/proton/engine/impl/TransportImpl.java  |  25 +-
 .../qpid/proton/engine/impl/TransportLink.java  |  29 ++-
 .../proton/engine/impl/TransportSession.java    |  54 +++-
 tests/python/proton_tests/engine.py             |  81 +++---
 36 files changed, 537 insertions(+), 442 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/64cb4faf/tests/python/proton_tests/engine.py
----------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[05/34] qpid-proton git commit: PROTON-490: run the "futurize" tool on all python source files

Posted by kg...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/python/proton_tests/transport.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/transport.py b/tests/python/proton_tests/transport.py
index febb029..e158a5b 100644
--- a/tests/python/proton_tests/transport.py
+++ b/tests/python/proton_tests/transport.py
@@ -17,7 +17,8 @@
 # under the License.
 #
 
-import os, common
+import os
+from . import common
 from proton import *
 
 
@@ -119,7 +120,8 @@ class TransportTest(Test):
     assert n > 0, n
     try:
       self.transport.close_head()
-    except TransportException, e:
+    except TransportException:
+      e = sys.exc_info()[1]
       assert "aborted" in str(e), str(e)
     n = self.transport.pending()
     assert n < 0, n
@@ -129,7 +131,8 @@ class TransportTest(Test):
     assert n > 0, n
     try:
       self.transport.close_tail()
-    except TransportException, e:
+    except TransportException:
+      e = sys.exc_info()[1]
       assert "aborted" in str(e), str(e)
     n = self.transport.capacity()
     assert n < 0, n

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/python/proton_tests/url.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/url.py b/tests/python/proton_tests/url.py
index 77a16ff..40a257c 100644
--- a/tests/python/proton_tests/url.py
+++ b/tests/python/proton_tests/url.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +19,7 @@
 #
 
 
-import common
+from . import common
 from proton import Url
 
 class UrlTest(common.Test):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/smoke/recv.py
----------------------------------------------------------------------
diff --git a/tests/smoke/recv.py b/tests/smoke/recv.py
index 3b2b0e5..e6aa2b6 100755
--- a/tests/smoke/recv.py
+++ b/tests/smoke/recv.py
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+from __future__ import print_function
 import sys
 from proton import *
 
@@ -16,7 +17,7 @@ messenger.start()
 while True:
   messenger.recv()
   messenger.get(message)
-  print "Got: %s" % message
+  print("Got: %s" % message)
   messenger.accept()
 
 messenger.stop()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/smoke/send.py
----------------------------------------------------------------------
diff --git a/tests/smoke/send.py b/tests/smoke/send.py
index 1aed9c8..7daee01 100755
--- a/tests/smoke/send.py
+++ b/tests/smoke/send.py
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+from __future__ import print_function
 import sys
 from proton import *
 
@@ -17,7 +18,7 @@ message.body = u"Hello World!"
 
 messenger.start()
 tracker = messenger.put(message)
-print "Put: %s" % message
+print("Put: %s" % message)
 messenger.send()
-print "Status: %s" % messenger.status(tracker)
+print("Status: %s" % messenger.status(tracker))
 messenger.stop()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/tools/apps/python/msgr-recv.py
----------------------------------------------------------------------
diff --git a/tests/tools/apps/python/msgr-recv.py b/tests/tools/apps/python/msgr-recv.py
index 73c2a3a..079c871 100755
--- a/tests/tools/apps/python/msgr-recv.py
+++ b/tests/tools/apps/python/msgr-recv.py
@@ -18,6 +18,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse, time
 import logging
 from proton import *

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/tools/apps/python/msgr-send.py
----------------------------------------------------------------------
diff --git a/tests/tools/apps/python/msgr-send.py b/tests/tools/apps/python/msgr-send.py
index 872122b..a2f67c5 100755
--- a/tests/tools/apps/python/msgr-send.py
+++ b/tests/tools/apps/python/msgr-send.py
@@ -18,6 +18,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse, time
 import logging
 from proton import *


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[09/34] qpid-proton git commit: PROTON-490: enable six.py support for operator method calls

Posted by kg...@apache.org.
PROTON-490: enable six.py support for operator method calls


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

Branch: refs/heads/master
Commit: 93ccc7364bfe28d3076a441409be8cbc5c88128b
Parents: adfe2a2
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Apr 22 15:09:45 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Apr 22 15:09:45 2015 -0400

----------------------------------------------------------------------
 tests/python/six.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/93ccc736/tests/python/six.py
----------------------------------------------------------------------
diff --git a/tests/python/six.py b/tests/python/six.py
index ffa3fe1..4b572bb 100644
--- a/tests/python/six.py
+++ b/tests/python/six.py
@@ -32,6 +32,17 @@ __author__ = "Benjamin Peterson <be...@python.org>"
 __version__ = "1.9.0"
 
 
+# begin QPID
+# added to support running the unit tests under JYTHON
+if not hasattr(operator, 'methodcaller'):
+    def _methodcaller(cls, name, *args, **kwargs):
+        def caller(obj):
+            return getattr(obj, name)(*args, **kwargs)
+        return caller
+    operator.methodcaller = classmethod(_methodcaller)
+# QPID end
+
+
 # Useful for very coarse version differentiation.
 PY2 = sys.version_info[0] == 2
 PY3 = sys.version_info[0] == 3


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[08/34] qpid-proton git commit: PROTON-490: JYTHON tests cannot access site six.py so include a copy

Posted by kg...@apache.org.
PROTON-490: JYTHON tests cannot access site six.py so include a copy


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

Branch: refs/heads/master
Commit: adfe2a20f0e07a6b8445b45975f15d1512599866
Parents: e87a6d3
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Apr 22 15:07:47 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Apr 22 15:07:47 2015 -0400

----------------------------------------------------------------------
 tests/python/six.py | 838 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 838 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/adfe2a20/tests/python/six.py
----------------------------------------------------------------------
diff --git a/tests/python/six.py b/tests/python/six.py
new file mode 100644
index 0000000..ffa3fe1
--- /dev/null
+++ b/tests/python/six.py
@@ -0,0 +1,838 @@
+"""Utilities for writing code that runs on Python 2 and 3"""
+
+# Copyright (c) 2010-2015 Benjamin Peterson
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+from __future__ import absolute_import
+
+import functools
+import itertools
+import operator
+import sys
+import types
+
+__author__ = "Benjamin Peterson <be...@python.org>"
+__version__ = "1.9.0"
+
+
+# Useful for very coarse version differentiation.
+PY2 = sys.version_info[0] == 2
+PY3 = sys.version_info[0] == 3
+
+if PY3:
+    string_types = str,
+    integer_types = int,
+    class_types = type,
+    text_type = str
+    binary_type = bytes
+
+    MAXSIZE = sys.maxsize
+else:
+    string_types = basestring,
+    integer_types = (int, long)
+    class_types = (type, types.ClassType)
+    text_type = unicode
+    binary_type = str
+
+    if sys.platform.startswith("java"):
+        # Jython always uses 32 bits.
+        MAXSIZE = int((1 << 31) - 1)
+    else:
+        # It's possible to have sizeof(long) != sizeof(Py_ssize_t).
+        class X(object):
+            def __len__(self):
+                return 1 << 31
+        try:
+            len(X())
+        except OverflowError:
+            # 32-bit
+            MAXSIZE = int((1 << 31) - 1)
+        else:
+            # 64-bit
+            MAXSIZE = int((1 << 63) - 1)
+        del X
+
+
+def _add_doc(func, doc):
+    """Add documentation to a function."""
+    func.__doc__ = doc
+
+
+def _import_module(name):
+    """Import module, returning the module after the last dot."""
+    __import__(name)
+    return sys.modules[name]
+
+
+class _LazyDescr(object):
+
+    def __init__(self, name):
+        self.name = name
+
+    def __get__(self, obj, tp):
+        result = self._resolve()
+        setattr(obj, self.name, result) # Invokes __set__.
+        try:
+            # This is a bit ugly, but it avoids running this again by
+            # removing this descriptor.
+            delattr(obj.__class__, self.name)
+        except AttributeError:
+            pass
+        return result
+
+
+class MovedModule(_LazyDescr):
+
+    def __init__(self, name, old, new=None):
+        super(MovedModule, self).__init__(name)
+        if PY3:
+            if new is None:
+                new = name
+            self.mod = new
+        else:
+            self.mod = old
+
+    def _resolve(self):
+        return _import_module(self.mod)
+
+    def __getattr__(self, attr):
+        _module = self._resolve()
+        value = getattr(_module, attr)
+        setattr(self, attr, value)
+        return value
+
+
+class _LazyModule(types.ModuleType):
+
+    def __init__(self, name):
+        super(_LazyModule, self).__init__(name)
+        self.__doc__ = self.__class__.__doc__
+
+    def __dir__(self):
+        attrs = ["__doc__", "__name__"]
+        attrs += [attr.name for attr in self._moved_attributes]
+        return attrs
+
+    # Subclasses should override this
+    _moved_attributes = []
+
+
+class MovedAttribute(_LazyDescr):
+
+    def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
+        super(MovedAttribute, self).__init__(name)
+        if PY3:
+            if new_mod is None:
+                new_mod = name
+            self.mod = new_mod
+            if new_attr is None:
+                if old_attr is None:
+                    new_attr = name
+                else:
+                    new_attr = old_attr
+            self.attr = new_attr
+        else:
+            self.mod = old_mod
+            if old_attr is None:
+                old_attr = name
+            self.attr = old_attr
+
+    def _resolve(self):
+        module = _import_module(self.mod)
+        return getattr(module, self.attr)
+
+
+class _SixMetaPathImporter(object):
+    """
+    A meta path importer to import six.moves and its submodules.
+
+    This class implements a PEP302 finder and loader. It should be compatible
+    with Python 2.5 and all existing versions of Python3
+    """
+    def __init__(self, six_module_name):
+        self.name = six_module_name
+        self.known_modules = {}
+
+    def _add_module(self, mod, *fullnames):
+        for fullname in fullnames:
+            self.known_modules[self.name + "." + fullname] = mod
+
+    def _get_module(self, fullname):
+        return self.known_modules[self.name + "." + fullname]
+
+    def find_module(self, fullname, path=None):
+        if fullname in self.known_modules:
+            return self
+        return None
+
+    def __get_module(self, fullname):
+        try:
+            return self.known_modules[fullname]
+        except KeyError:
+            raise ImportError("This loader does not know module " + fullname)
+
+    def load_module(self, fullname):
+        try:
+            # in case of a reload
+            return sys.modules[fullname]
+        except KeyError:
+            pass
+        mod = self.__get_module(fullname)
+        if isinstance(mod, MovedModule):
+            mod = mod._resolve()
+        else:
+            mod.__loader__ = self
+        sys.modules[fullname] = mod
+        return mod
+
+    def is_package(self, fullname):
+        """
+        Return true, if the named module is a package.
+
+        We need this method to get correct spec objects with
+        Python 3.4 (see PEP451)
+        """
+        return hasattr(self.__get_module(fullname), "__path__")
+
+    def get_code(self, fullname):
+        """Return None
+
+        Required, if is_package is implemented"""
+        self.__get_module(fullname)  # eventually raises ImportError
+        return None
+    get_source = get_code  # same as get_code
+
+_importer = _SixMetaPathImporter(__name__)
+
+
+class _MovedItems(_LazyModule):
+    """Lazy loading of moved objects"""
+    __path__ = []  # mark as package
+
+
+_moved_attributes = [
+    MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
+    MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
+    MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"),
+    MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
+    MovedAttribute("intern", "__builtin__", "sys"),
+    MovedAttribute("map", "itertools", "builtins", "imap", "map"),
+    MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
+    MovedAttribute("reload_module", "__builtin__", "imp", "reload"),
+    MovedAttribute("reduce", "__builtin__", "functools"),
+    MovedAttribute("shlex_quote", "pipes", "shlex", "quote"),
+    MovedAttribute("StringIO", "StringIO", "io"),
+    MovedAttribute("UserDict", "UserDict", "collections"),
+    MovedAttribute("UserList", "UserList", "collections"),
+    MovedAttribute("UserString", "UserString", "collections"),
+    MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
+    MovedAttribute("zip", "itertools", "builtins", "izip", "zip"),
+    MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
+
+    MovedModule("builtins", "__builtin__"),
+    MovedModule("configparser", "ConfigParser"),
+    MovedModule("copyreg", "copy_reg"),
+    MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
+    MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"),
+    MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
+    MovedModule("http_cookies", "Cookie", "http.cookies"),
+    MovedModule("html_entities", "htmlentitydefs", "html.entities"),
+    MovedModule("html_parser", "HTMLParser", "html.parser"),
+    MovedModule("http_client", "httplib", "http.client"),
+    MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"),
+    MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"),
+    MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"),
+    MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
+    MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
+    MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"),
+    MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"),
+    MovedModule("cPickle", "cPickle", "pickle"),
+    MovedModule("queue", "Queue"),
+    MovedModule("reprlib", "repr"),
+    MovedModule("socketserver", "SocketServer"),
+    MovedModule("_thread", "thread", "_thread"),
+    MovedModule("tkinter", "Tkinter"),
+    MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"),
+    MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"),
+    MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"),
+    MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"),
+    MovedModule("tkinter_tix", "Tix", "tkinter.tix"),
+    MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"),
+    MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"),
+    MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"),
+    MovedModule("tkinter_colorchooser", "tkColorChooser",
+                "tkinter.colorchooser"),
+    MovedModule("tkinter_commondialog", "tkCommonDialog",
+                "tkinter.commondialog"),
+    MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"),
+    MovedModule("tkinter_font", "tkFont", "tkinter.font"),
+    MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"),
+    MovedModule("tkinter_tksimpledialog", "tkSimpleDialog",
+                "tkinter.simpledialog"),
+    MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"),
+    MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"),
+    MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"),
+    MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"),
+    MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"),
+    MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"),
+    MovedModule("winreg", "_winreg"),
+]
+for attr in _moved_attributes:
+    setattr(_MovedItems, attr.name, attr)
+    if isinstance(attr, MovedModule):
+        _importer._add_module(attr, "moves." + attr.name)
+del attr
+
+_MovedItems._moved_attributes = _moved_attributes
+
+moves = _MovedItems(__name__ + ".moves")
+_importer._add_module(moves, "moves")
+
+
+class Module_six_moves_urllib_parse(_LazyModule):
+    """Lazy loading of moved objects in six.moves.urllib_parse"""
+
+
+_urllib_parse_moved_attributes = [
+    MovedAttribute("ParseResult", "urlparse", "urllib.parse"),
+    MovedAttribute("SplitResult", "urlparse", "urllib.parse"),
+    MovedAttribute("parse_qs", "urlparse", "urllib.parse"),
+    MovedAttribute("parse_qsl", "urlparse", "urllib.parse"),
+    MovedAttribute("urldefrag", "urlparse", "urllib.parse"),
+    MovedAttribute("urljoin", "urlparse", "urllib.parse"),
+    MovedAttribute("urlparse", "urlparse", "urllib.parse"),
+    MovedAttribute("urlsplit", "urlparse", "urllib.parse"),
+    MovedAttribute("urlunparse", "urlparse", "urllib.parse"),
+    MovedAttribute("urlunsplit", "urlparse", "urllib.parse"),
+    MovedAttribute("quote", "urllib", "urllib.parse"),
+    MovedAttribute("quote_plus", "urllib", "urllib.parse"),
+    MovedAttribute("unquote", "urllib", "urllib.parse"),
+    MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
+    MovedAttribute("urlencode", "urllib", "urllib.parse"),
+    MovedAttribute("splitquery", "urllib", "urllib.parse"),
+    MovedAttribute("splittag", "urllib", "urllib.parse"),
+    MovedAttribute("splituser", "urllib", "urllib.parse"),
+    MovedAttribute("uses_fragment", "urlparse", "urllib.parse"),
+    MovedAttribute("uses_netloc", "urlparse", "urllib.parse"),
+    MovedAttribute("uses_params", "urlparse", "urllib.parse"),
+    MovedAttribute("uses_query", "urlparse", "urllib.parse"),
+    MovedAttribute("uses_relative", "urlparse", "urllib.parse"),
+]
+for attr in _urllib_parse_moved_attributes:
+    setattr(Module_six_moves_urllib_parse, attr.name, attr)
+del attr
+
+Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes
+
+_importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"),
+                      "moves.urllib_parse", "moves.urllib.parse")
+
+
+class Module_six_moves_urllib_error(_LazyModule):
+    """Lazy loading of moved objects in six.moves.urllib_error"""
+
+
+_urllib_error_moved_attributes = [
+    MovedAttribute("URLError", "urllib2", "urllib.error"),
+    MovedAttribute("HTTPError", "urllib2", "urllib.error"),
+    MovedAttribute("ContentTooShortError", "urllib", "urllib.error"),
+]
+for attr in _urllib_error_moved_attributes:
+    setattr(Module_six_moves_urllib_error, attr.name, attr)
+del attr
+
+Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes
+
+_importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"),
+                      "moves.urllib_error", "moves.urllib.error")
+
+
+class Module_six_moves_urllib_request(_LazyModule):
+    """Lazy loading of moved objects in six.moves.urllib_request"""
+
+
+_urllib_request_moved_attributes = [
+    MovedAttribute("urlopen", "urllib2", "urllib.request"),
+    MovedAttribute("install_opener", "urllib2", "urllib.request"),
+    MovedAttribute("build_opener", "urllib2", "urllib.request"),
+    MovedAttribute("pathname2url", "urllib", "urllib.request"),
+    MovedAttribute("url2pathname", "urllib", "urllib.request"),
+    MovedAttribute("getproxies", "urllib", "urllib.request"),
+    MovedAttribute("Request", "urllib2", "urllib.request"),
+    MovedAttribute("OpenerDirector", "urllib2", "urllib.request"),
+    MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"),
+    MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"),
+    MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"),
+    MovedAttribute("ProxyHandler", "urllib2", "urllib.request"),
+    MovedAttribute("BaseHandler", "urllib2", "urllib.request"),
+    MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"),
+    MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"),
+    MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"),
+    MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"),
+    MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"),
+    MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"),
+    MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"),
+    MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"),
+    MovedAttribute("HTTPHandler", "urllib2", "urllib.request"),
+    MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"),
+    MovedAttribute("FileHandler", "urllib2", "urllib.request"),
+    MovedAttribute("FTPHandler", "urllib2", "urllib.request"),
+    MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"),
+    MovedAttribute("UnknownHandler", "urllib2", "urllib.request"),
+    MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"),
+    MovedAttribute("urlretrieve", "urllib", "urllib.request"),
+    MovedAttribute("urlcleanup", "urllib", "urllib.request"),
+    MovedAttribute("URLopener", "urllib", "urllib.request"),
+    MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
+    MovedAttribute("proxy_bypass", "urllib", "urllib.request"),
+]
+for attr in _urllib_request_moved_attributes:
+    setattr(Module_six_moves_urllib_request, attr.name, attr)
+del attr
+
+Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes
+
+_importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"),
+                      "moves.urllib_request", "moves.urllib.request")
+
+
+class Module_six_moves_urllib_response(_LazyModule):
+    """Lazy loading of moved objects in six.moves.urllib_response"""
+
+
+_urllib_response_moved_attributes = [
+    MovedAttribute("addbase", "urllib", "urllib.response"),
+    MovedAttribute("addclosehook", "urllib", "urllib.response"),
+    MovedAttribute("addinfo", "urllib", "urllib.response"),
+    MovedAttribute("addinfourl", "urllib", "urllib.response"),
+]
+for attr in _urllib_response_moved_attributes:
+    setattr(Module_six_moves_urllib_response, attr.name, attr)
+del attr
+
+Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes
+
+_importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"),
+                      "moves.urllib_response", "moves.urllib.response")
+
+
+class Module_six_moves_urllib_robotparser(_LazyModule):
+    """Lazy loading of moved objects in six.moves.urllib_robotparser"""
+
+
+_urllib_robotparser_moved_attributes = [
+    MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"),
+]
+for attr in _urllib_robotparser_moved_attributes:
+    setattr(Module_six_moves_urllib_robotparser, attr.name, attr)
+del attr
+
+Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes
+
+_importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"),
+                      "moves.urllib_robotparser", "moves.urllib.robotparser")
+
+
+class Module_six_moves_urllib(types.ModuleType):
+    """Create a six.moves.urllib namespace that resembles the Python 3 namespace"""
+    __path__ = []  # mark as package
+    parse = _importer._get_module("moves.urllib_parse")
+    error = _importer._get_module("moves.urllib_error")
+    request = _importer._get_module("moves.urllib_request")
+    response = _importer._get_module("moves.urllib_response")
+    robotparser = _importer._get_module("moves.urllib_robotparser")
+
+    def __dir__(self):
+        return ['parse', 'error', 'request', 'response', 'robotparser']
+
+_importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"),
+                      "moves.urllib")
+
+
+def add_move(move):
+    """Add an item to six.moves."""
+    setattr(_MovedItems, move.name, move)
+
+
+def remove_move(name):
+    """Remove item from six.moves."""
+    try:
+        delattr(_MovedItems, name)
+    except AttributeError:
+        try:
+            del moves.__dict__[name]
+        except KeyError:
+            raise AttributeError("no such move, %r" % (name,))
+
+
+if PY3:
+    _meth_func = "__func__"
+    _meth_self = "__self__"
+
+    _func_closure = "__closure__"
+    _func_code = "__code__"
+    _func_defaults = "__defaults__"
+    _func_globals = "__globals__"
+else:
+    _meth_func = "im_func"
+    _meth_self = "im_self"
+
+    _func_closure = "func_closure"
+    _func_code = "func_code"
+    _func_defaults = "func_defaults"
+    _func_globals = "func_globals"
+
+
+try:
+    advance_iterator = next
+except NameError:
+    def advance_iterator(it):
+        return it.next()
+next = advance_iterator
+
+
+try:
+    callable = callable
+except NameError:
+    def callable(obj):
+        return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)
+
+
+if PY3:
+    def get_unbound_function(unbound):
+        return unbound
+
+    create_bound_method = types.MethodType
+
+    Iterator = object
+else:
+    def get_unbound_function(unbound):
+        return unbound.im_func
+
+    def create_bound_method(func, obj):
+        return types.MethodType(func, obj, obj.__class__)
+
+    class Iterator(object):
+
+        def next(self):
+            return type(self).__next__(self)
+
+    callable = callable
+_add_doc(get_unbound_function,
+         """Get the function out of a possibly unbound function""")
+
+
+get_method_function = operator.attrgetter(_meth_func)
+get_method_self = operator.attrgetter(_meth_self)
+get_function_closure = operator.attrgetter(_func_closure)
+get_function_code = operator.attrgetter(_func_code)
+get_function_defaults = operator.attrgetter(_func_defaults)
+get_function_globals = operator.attrgetter(_func_globals)
+
+
+if PY3:
+    def iterkeys(d, **kw):
+        return iter(d.keys(**kw))
+
+    def itervalues(d, **kw):
+        return iter(d.values(**kw))
+
+    def iteritems(d, **kw):
+        return iter(d.items(**kw))
+
+    def iterlists(d, **kw):
+        return iter(d.lists(**kw))
+
+    viewkeys = operator.methodcaller("keys")
+
+    viewvalues = operator.methodcaller("values")
+
+    viewitems = operator.methodcaller("items")
+else:
+    def iterkeys(d, **kw):
+        return iter(d.iterkeys(**kw))
+
+    def itervalues(d, **kw):
+        return iter(d.itervalues(**kw))
+
+    def iteritems(d, **kw):
+        return iter(d.iteritems(**kw))
+
+    def iterlists(d, **kw):
+        return iter(d.iterlists(**kw))
+
+    viewkeys = operator.methodcaller("viewkeys")
+
+    viewvalues = operator.methodcaller("viewvalues")
+
+    viewitems = operator.methodcaller("viewitems")
+
+_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.")
+_add_doc(itervalues, "Return an iterator over the values of a dictionary.")
+_add_doc(iteritems,
+         "Return an iterator over the (key, value) pairs of a dictionary.")
+_add_doc(iterlists,
+         "Return an iterator over the (key, [values]) pairs of a dictionary.")
+
+
+if PY3:
+    def b(s):
+        return s.encode("latin-1")
+    def u(s):
+        return s
+    unichr = chr
+    if sys.version_info[1] <= 1:
+        def int2byte(i):
+            return bytes((i,))
+    else:
+        # This is about 2x faster than the implementation above on 3.2+
+        int2byte = operator.methodcaller("to_bytes", 1, "big")
+    byte2int = operator.itemgetter(0)
+    indexbytes = operator.getitem
+    iterbytes = iter
+    import io
+    StringIO = io.StringIO
+    BytesIO = io.BytesIO
+    _assertCountEqual = "assertCountEqual"
+    _assertRaisesRegex = "assertRaisesRegex"
+    _assertRegex = "assertRegex"
+else:
+    def b(s):
+        return s
+    # Workaround for standalone backslash
+    def u(s):
+        return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
+    unichr = unichr
+    int2byte = chr
+    def byte2int(bs):
+        return ord(bs[0])
+    def indexbytes(buf, i):
+        return ord(buf[i])
+    iterbytes = functools.partial(itertools.imap, ord)
+    import StringIO
+    StringIO = BytesIO = StringIO.StringIO
+    _assertCountEqual = "assertItemsEqual"
+    _assertRaisesRegex = "assertRaisesRegexp"
+    _assertRegex = "assertRegexpMatches"
+_add_doc(b, """Byte literal""")
+_add_doc(u, """Text literal""")
+
+
+def assertCountEqual(self, *args, **kwargs):
+    return getattr(self, _assertCountEqual)(*args, **kwargs)
+
+
+def assertRaisesRegex(self, *args, **kwargs):
+    return getattr(self, _assertRaisesRegex)(*args, **kwargs)
+
+
+def assertRegex(self, *args, **kwargs):
+    return getattr(self, _assertRegex)(*args, **kwargs)
+
+
+if PY3:
+    exec_ = getattr(moves.builtins, "exec")
+
+
+    def reraise(tp, value, tb=None):
+        if value is None:
+            value = tp()
+        if value.__traceback__ is not tb:
+            raise value.with_traceback(tb)
+        raise value
+
+else:
+    def exec_(_code_, _globs_=None, _locs_=None):
+        """Execute code in a namespace."""
+        if _globs_ is None:
+            frame = sys._getframe(1)
+            _globs_ = frame.f_globals
+            if _locs_ is None:
+                _locs_ = frame.f_locals
+            del frame
+        elif _locs_ is None:
+            _locs_ = _globs_
+        exec("""exec _code_ in _globs_, _locs_""")
+
+
+    exec_("""def reraise(tp, value, tb=None):
+    raise tp, value, tb
+""")
+
+
+if sys.version_info[:2] == (3, 2):
+    exec_("""def raise_from(value, from_value):
+    if from_value is None:
+        raise value
+    raise value from from_value
+""")
+elif sys.version_info[:2] > (3, 2):
+    exec_("""def raise_from(value, from_value):
+    raise value from from_value
+""")
+else:
+    def raise_from(value, from_value):
+        raise value
+
+
+print_ = getattr(moves.builtins, "print", None)
+if print_ is None:
+    def print_(*args, **kwargs):
+        """The new-style print function for Python 2.4 and 2.5."""
+        fp = kwargs.pop("file", sys.stdout)
+        if fp is None:
+            return
+        def write(data):
+            if not isinstance(data, basestring):
+                data = str(data)
+            # If the file has an encoding, encode unicode with it.
+            if (isinstance(fp, file) and
+                isinstance(data, unicode) and
+                fp.encoding is not None):
+                errors = getattr(fp, "errors", None)
+                if errors is None:
+                    errors = "strict"
+                data = data.encode(fp.encoding, errors)
+            fp.write(data)
+        want_unicode = False
+        sep = kwargs.pop("sep", None)
+        if sep is not None:
+            if isinstance(sep, unicode):
+                want_unicode = True
+            elif not isinstance(sep, str):
+                raise TypeError("sep must be None or a string")
+        end = kwargs.pop("end", None)
+        if end is not None:
+            if isinstance(end, unicode):
+                want_unicode = True
+            elif not isinstance(end, str):
+                raise TypeError("end must be None or a string")
+        if kwargs:
+            raise TypeError("invalid keyword arguments to print()")
+        if not want_unicode:
+            for arg in args:
+                if isinstance(arg, unicode):
+                    want_unicode = True
+                    break
+        if want_unicode:
+            newline = unicode("\n")
+            space = unicode(" ")
+        else:
+            newline = "\n"
+            space = " "
+        if sep is None:
+            sep = space
+        if end is None:
+            end = newline
+        for i, arg in enumerate(args):
+            if i:
+                write(sep)
+            write(arg)
+        write(end)
+if sys.version_info[:2] < (3, 3):
+    _print = print_
+    def print_(*args, **kwargs):
+        fp = kwargs.get("file", sys.stdout)
+        flush = kwargs.pop("flush", False)
+        _print(*args, **kwargs)
+        if flush and fp is not None:
+            fp.flush()
+
+_add_doc(reraise, """Reraise an exception.""")
+
+if sys.version_info[0:2] < (3, 4):
+    def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
+              updated=functools.WRAPPER_UPDATES):
+        def wrapper(f):
+            f = functools.wraps(wrapped, assigned, updated)(f)
+            f.__wrapped__ = wrapped
+            return f
+        return wrapper
+else:
+    wraps = functools.wraps
+
+def with_metaclass(meta, *bases):
+    """Create a base class with a metaclass."""
+    # This requires a bit of explanation: the basic idea is to make a dummy
+    # metaclass for one level of class instantiation that replaces itself with
+    # the actual metaclass.
+    class metaclass(meta):
+        def __new__(cls, name, this_bases, d):
+            return meta(name, bases, d)
+    return type.__new__(metaclass, 'temporary_class', (), {})
+
+
+def add_metaclass(metaclass):
+    """Class decorator for creating a class with a metaclass."""
+    def wrapper(cls):
+        orig_vars = cls.__dict__.copy()
+        slots = orig_vars.get('__slots__')
+        if slots is not None:
+            if isinstance(slots, str):
+                slots = [slots]
+            for slots_var in slots:
+                orig_vars.pop(slots_var)
+        orig_vars.pop('__dict__', None)
+        orig_vars.pop('__weakref__', None)
+        return metaclass(cls.__name__, cls.__bases__, orig_vars)
+    return wrapper
+
+
+def python_2_unicode_compatible(klass):
+    """
+    A decorator that defines __unicode__ and __str__ methods under Python 2.
+    Under Python 3 it does nothing.
+
+    To support Python 2 and 3 with a single code base, define a __str__ method
+    returning text and apply this decorator to the class.
+    """
+    if PY2:
+        if '__str__' not in klass.__dict__:
+            raise ValueError("@python_2_unicode_compatible cannot be applied "
+                             "to %s because it doesn't define __str__()." %
+                             klass.__name__)
+        klass.__unicode__ = klass.__str__
+        klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
+    return klass
+
+
+# Complete the moves implementation.
+# This code is at the end of this module to speed up module loading.
+# Turn this module into a package.
+__path__ = []  # required for PEP 302 and PEP 451
+__package__ = __name__  # see PEP 366 @ReservedAssignment
+if globals().get("__spec__") is not None:
+    __spec__.submodule_search_locations = []  # PEP 451 @UndefinedVariable
+# Remove other six meta path importers, since they cause problems. This can
+# happen if six is removed from sys.modules and then reloaded. (Setuptools does
+# this for some reason.)
+if sys.meta_path:
+    for i, importer in enumerate(sys.meta_path):
+        # Here's some real nastiness: Another "instance" of the six module might
+        # be floating around. Therefore, we can't use isinstance() to check for
+        # the six meta path importer, since the other six instance will have
+        # inserted an importer with different class.
+        if (type(importer).__name__ == "_SixMetaPathImporter" and
+            importer.name == __name__):
+            del sys.meta_path[i]
+            break
+    del i, importer
+# Finally, add the importer to the meta path import hook.
+sys.meta_path.append(_importer)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[27/34] qpid-proton git commit: PROTON-490: include python3.3 in allowable test cases

Posted by kg...@apache.org.
PROTON-490: include python3.3 in allowable test cases


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

Branch: refs/heads/master
Commit: dff246b0b6e7f8fac38ed217e30910cbdf07eeea
Parents: 0d1da5c
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Jun 17 15:58:10 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Jun 17 15:58:10 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/tox.ini | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/dff246b0/proton-c/bindings/python/tox.ini
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/tox.ini b/proton-c/bindings/python/tox.ini
index acfa5a1..6bbe1fc 100644
--- a/proton-c/bindings/python/tox.ini
+++ b/proton-c/bindings/python/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py27,py34
+envlist = py27,py33,py34
 minversion = 1.4
 skipdist = True
 
@@ -26,5 +26,8 @@ commands = python setup.py build_sphinx
 [testenv:py27]
 platform = linux|linux2
 
+[testenv:py33]
+platform = linux|linux2
+
 [testenv:py34]
-platform = linux|linux2
\ No newline at end of file
+platform = linux|linux2


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[22/34] qpid-proton git commit: Merge branch 'master' into kgiusti-python3

Posted by kg...@apache.org.
Merge branch 'master' into kgiusti-python3

Conflicts:
	proton-c/bindings/python/proton/__init__.py
	tests/python/proton_tests/sasl.py


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

Branch: refs/heads/master
Commit: 2721c639fc5e750291d4badd081d6f6d1207434f
Parents: 43a61bb c2c178c
Author: Ken Giusti <kg...@apache.org>
Authored: Mon Jun 15 13:19:55 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Jun 15 13:19:55 2015 -0400

----------------------------------------------------------------------
 .gitattributes                                  |   2 +
 .gitignore                                      |   6 +
 .travis.yml                                     |   2 +-
 LICENSE                                         |   6 +
 README.md                                       |   4 +
 appveyor.yml                                    |  16 +
 bin/export.sh                                   |  29 +-
 examples/engine/java/drain                      |   2 +-
 examples/engine/java/pom.xml                    |   2 +-
 examples/engine/java/server                     |   2 +-
 examples/engine/java/spout                      |   2 +-
 examples/go/README.md                           |  69 ++
 examples/go/event/broker.go                     | 186 ++--
 examples/go/example.go                          |  54 --
 examples/go/receive.go                          |  99 +-
 examples/go/send.go                             | 117 ++-
 examples/python/README                          |  22 +
 examples/python/reactor/send.py                 |   3 +
 examples/ruby/engine_recv.rb                    | 158 ++++
 examples/ruby/engine_send.rb                    | 143 +++
 examples/ruby/lib/driver.rb                     |  69 ++
 examples/ruby/lib/qpid_examples.rb              |  28 +
 examples/ruby/lib/selectable.rb                 | 120 +++
 examples/ruby/messenger/README.md               | 163 ++++
 examples/ruby/messenger/client.rb               |   2 +-
 examples/ruby/messenger/mailserver.rb           |   3 +-
 examples/ruby/messenger/nonblocking_recv.rb     | 145 +++
 examples/ruby/messenger/passive_recv.rb         | 140 ---
 examples/ruby/messenger/recv.rb                 |   2 +-
 examples/ruby/messenger/send.rb                 |   2 +-
 examples/ruby/wrapper_test.rb                   |  82 ++
 proton-c/CMakeLists.txt                         |  52 +-
 proton-c/bindings/CMakeLists.txt                |   2 +-
 proton-c/bindings/go/README.md                  | 196 +---
 proton-c/bindings/go/WARNING_EXPERIMENTAL       |   1 -
 proton-c/bindings/go/src/Makefile               |  25 -
 proton-c/bindings/go/src/genwrap.go             | 398 --------
 .../go/src/qpid.apache.org/proton/doc.go        |  36 -
 .../go/src/qpid.apache.org/proton/dummy.go      |  82 --
 .../go/src/qpid.apache.org/proton/error.go      | 111 ---
 .../go/src/qpid.apache.org/proton/event/doc.go  |  28 -
 .../src/qpid.apache.org/proton/event/error.go   |  77 --
 .../qpid.apache.org/proton/event/handlers.go    | 328 -------
 .../go/src/qpid.apache.org/proton/event/pump.go | 262 ------
 .../qpid.apache.org/proton/event/wrappers.go    | 137 ---
 .../proton/event/wrappers_gen.go                | 505 ----------
 .../src/qpid.apache.org/proton/interop_test.go  | 308 -------
 .../go/src/qpid.apache.org/proton/marshal.go    | 229 -----
 .../go/src/qpid.apache.org/proton/message.go    | 388 --------
 .../src/qpid.apache.org/proton/message_test.go  |  90 --
 .../go/src/qpid.apache.org/proton/types.go      | 193 ----
 .../go/src/qpid.apache.org/proton/unmarshal.go  | 530 -----------
 .../go/src/qpid.apache.org/proton/url.go        |  95 --
 .../go/src/qpid.apache.org/proton/url_test.go   |  51 --
 proton-c/bindings/javascript/CMakeLists.txt     |   9 +-
 proton-c/bindings/javascript/binding.c          |   2 +
 proton-c/bindings/php/php.i                     |  15 -
 proton-c/bindings/python/CMakeLists.txt         |  13 +
 proton-c/bindings/python/MANIFEST.in            |   2 +
 proton-c/bindings/python/cproton.i              |  36 +
 proton-c/bindings/python/docs/Makefile          | 153 ----
 proton-c/bindings/python/docs/README            |   5 -
 proton-c/bindings/python/docs/conf.py           | 242 +++++
 proton-c/bindings/python/docs/index.rst         |  11 +
 proton-c/bindings/python/docs/make.bat          | 190 ----
 proton-c/bindings/python/docs/overview.rst      | 160 ++++
 proton-c/bindings/python/docs/source/conf.py    | 242 -----
 proton-c/bindings/python/docs/source/index.rst  |  24 -
 .../bindings/python/docs/source/overview.rst    | 161 ----
 .../bindings/python/docs/source/reference.rst   |  44 -
 .../bindings/python/docs/source/tutorial.rst    | 301 ------
 proton-c/bindings/python/docs/tutorial.rst      | 301 ++++++
 proton-c/bindings/python/proton/__init__.py     |  70 +-
 proton-c/bindings/python/proton/handlers.py     |   2 +-
 proton-c/bindings/python/proton/reactor.py      |  27 +-
 proton-c/bindings/python/setup.py               | 305 ++++++-
 .../python/setuputils/PYZMQ_LICENSE.BSD         |  32 +
 proton-c/bindings/python/setuputils/__init__.py |   0
 proton-c/bindings/python/setuputils/bundle.py   |  84 ++
 proton-c/bindings/python/setuputils/log.py      |  46 +
 proton-c/bindings/python/setuputils/misc.py     |  55 ++
 proton-c/bindings/python/tox.ini                |  32 +
 proton-c/bindings/ruby/.yardopts                |   1 +
 proton-c/bindings/ruby/lib/codec/data.rb        | 912 +++++++++++++++++++
 proton-c/bindings/ruby/lib/codec/mapping.rb     | 169 ++++
 proton-c/bindings/ruby/lib/core/connection.rb   | 328 +++++++
 proton-c/bindings/ruby/lib/core/delivery.rb     | 271 ++++++
 proton-c/bindings/ruby/lib/core/disposition.rb  | 158 ++++
 proton-c/bindings/ruby/lib/core/endpoint.rb     | 115 +++
 proton-c/bindings/ruby/lib/core/exceptions.rb   | 116 +++
 proton-c/bindings/ruby/lib/core/link.rb         | 387 ++++++++
 proton-c/bindings/ruby/lib/core/message.rb      | 633 +++++++++++++
 proton-c/bindings/ruby/lib/core/receiver.rb     |  95 ++
 proton-c/bindings/ruby/lib/core/sasl.rb         |  94 ++
 proton-c/bindings/ruby/lib/core/sender.rb       |  76 ++
 proton-c/bindings/ruby/lib/core/session.rb      | 163 ++++
 proton-c/bindings/ruby/lib/core/ssl.rb          | 160 ++++
 proton-c/bindings/ruby/lib/core/ssl_details.rb  |  33 +
 proton-c/bindings/ruby/lib/core/ssl_domain.rb   | 156 ++++
 proton-c/bindings/ruby/lib/core/terminus.rb     | 218 +++++
 proton-c/bindings/ruby/lib/core/transport.rb    | 412 +++++++++
 proton-c/bindings/ruby/lib/event/collector.rb   | 148 +++
 proton-c/bindings/ruby/lib/event/event.rb       | 296 ++++++
 proton-c/bindings/ruby/lib/event/event_base.rb  |  91 ++
 proton-c/bindings/ruby/lib/event/event_type.rb  |  71 ++
 proton-c/bindings/ruby/lib/messenger/filters.rb |  64 ++
 .../bindings/ruby/lib/messenger/messenger.rb    | 702 ++++++++++++++
 .../bindings/ruby/lib/messenger/selectable.rb   | 124 +++
 .../bindings/ruby/lib/messenger/subscription.rb |  37 +
 proton-c/bindings/ruby/lib/messenger/tracker.rb |  38 +
 .../ruby/lib/messenger/tracker_status.rb        |  69 ++
 proton-c/bindings/ruby/lib/qpid_proton.rb       |  95 +-
 proton-c/bindings/ruby/lib/qpid_proton/array.rb | 173 ----
 proton-c/bindings/ruby/lib/qpid_proton/data.rb  | 788 ----------------
 .../bindings/ruby/lib/qpid_proton/described.rb  |  66 --
 .../ruby/lib/qpid_proton/exception_handling.rb  | 127 ---
 .../bindings/ruby/lib/qpid_proton/exceptions.rb |  85 --
 .../bindings/ruby/lib/qpid_proton/filters.rb    |  67 --
 proton-c/bindings/ruby/lib/qpid_proton/hash.rb  |  86 --
 .../bindings/ruby/lib/qpid_proton/mapping.rb    | 170 ----
 .../bindings/ruby/lib/qpid_proton/message.rb    | 621 -------------
 .../bindings/ruby/lib/qpid_proton/messenger.rb  | 702 --------------
 .../bindings/ruby/lib/qpid_proton/selectable.rb | 126 ---
 .../bindings/ruby/lib/qpid_proton/strings.rb    |  65 --
 .../ruby/lib/qpid_proton/subscription.rb        |  41 -
 .../bindings/ruby/lib/qpid_proton/tracker.rb    |  42 -
 .../ruby/lib/qpid_proton/tracker_status.rb      |  73 --
 .../bindings/ruby/lib/qpid_proton/version.rb    |  32 -
 proton-c/bindings/ruby/lib/types/array.rb       | 172 ++++
 proton-c/bindings/ruby/lib/types/described.rb   |  63 ++
 proton-c/bindings/ruby/lib/types/hash.rb        |  87 ++
 proton-c/bindings/ruby/lib/types/strings.rb     |  62 ++
 .../bindings/ruby/lib/util/class_wrapper.rb     |  52 ++
 proton-c/bindings/ruby/lib/util/condition.rb    |  45 +
 proton-c/bindings/ruby/lib/util/constants.rb    |  85 ++
 proton-c/bindings/ruby/lib/util/engine.rb       |  82 ++
 .../bindings/ruby/lib/util/error_handler.rb     | 127 +++
 proton-c/bindings/ruby/lib/util/swig_helper.rb  | 114 +++
 proton-c/bindings/ruby/lib/util/uuid.rb         |  32 +
 proton-c/bindings/ruby/lib/util/version.rb      |  30 +
 proton-c/bindings/ruby/lib/util/wrapper.rb      | 124 +++
 proton-c/bindings/ruby/ruby.i                   | 119 +++
 proton-c/include/proton/object.h                |   9 +-
 proton-c/include/proton/reactor.h               |   2 +
 proton-c/include/proton/sasl.h                  |  13 +
 proton-c/include/proton/ssl.h                   |  15 +
 proton-c/include/proton/transport.h             |   2 +-
 proton-c/src/buffer.c                           |  90 +-
 proton-c/src/codec/codec.c                      | 195 ++--
 proton-c/src/codec/decoder.c                    |  28 +-
 proton-c/src/config.h                           |  26 +
 proton-c/src/engine/engine-internal.h           |  10 -
 proton-c/src/engine/engine.c                    | 124 +--
 proton-c/src/error.c                            |   8 +-
 proton-c/src/messenger/messenger.c              |  42 +-
 proton-c/src/messenger/store.c                  |  22 +-
 proton-c/src/object/list.c                      |  11 +-
 proton-c/src/object/map.c                       |  16 +-
 proton-c/src/object/object.c                    |   9 +-
 proton-c/src/parser.c                           | 129 ++-
 proton-c/src/platform.c                         |  48 +-
 proton-c/src/platform.h                         |  22 +-
 proton-c/src/posix/io.c                         |   2 +-
 proton-c/src/reactor/acceptor.c                 |  15 +
 proton-c/src/sasl/cyrus_sasl.c                  | 888 +++++-------------
 proton-c/src/sasl/none_sasl.c                   | 490 +++-------
 proton-c/src/sasl/sasl-internal.h               |  60 +-
 proton-c/src/sasl/sasl.c                        | 505 +++++++++-
 proton-c/src/scanner.c                          |  92 +-
 proton-c/src/ssl/openssl.c                      |  49 +-
 proton-c/src/ssl/ssl-internal.h                 |   4 +-
 proton-c/src/ssl/ssl_stub.c                     |  10 +
 proton-c/src/transport/transport.c              | 209 ++---
 proton-c/src/util.c                             |  31 +-
 proton-c/src/util.h                             |  10 +-
 proton-c/src/windows/schannel.c                 |  37 +-
 .../org/apache/qpid/proton/engine/Sasl.java     |  13 +
 .../qpid/proton/engine/impl/SaslImpl.java       |  22 +
 proton-j/src/main/resources/cengine.py          |   3 +
 proton-j/src/main/resources/csasl.py            |  19 +
 .../qpid/proton/systemtests/SaslTest.java       | 100 ++
 tests/python/proton_tests/common.py             |  12 +-
 tests/python/proton_tests/engine.py             |  47 +
 tests/python/proton_tests/sasl.py               | 248 ++++-
 tests/python/proton_tests/ssl.py                |  62 +-
 tests/python/proton_tests/transport.py          |  15 +
 tests/tools/apps/c/reactor-recv.c               |   8 +-
 187 files changed, 12313 insertions(+), 10517 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2721c639/proton-c/bindings/python/cproton.i
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2721c639/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --cc proton-c/bindings/python/proton/__init__.py
index 2098ef9,9432bd8..747bfad
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@@ -79,16 -76,16 +79,16 @@@ except ImportError
    rand = random.Random()
    rand.seed((os.getpid(), time.time(), socket.gethostname()))
    def random_uuid():
 -    bytes = [rand.randint(0, 255) for i in xrange(16)]
 +    data = [rand.randint(0, 255) for i in xrange(16)]
  
      # From RFC4122, the version bits are set to 0100
-     data[7] &= 0x0F
-     data[7] |= 0x40
 -    bytes[6] &= 0x0F
 -    bytes[6] |= 0x40
++    data[6] &= 0x0F
++    data[6] |= 0x40
  
      # From RFC4122, the top two bits of byte 8 get set to 01
 -    bytes[8] &= 0x3F
 -    bytes[8] |= 0x80
 -    return "".join(map(chr, bytes))
 +    data[8] &= 0x3F
 +    data[8] |= 0x80
 +    return "".join(map(chr, data))
  
    def uuid4():
      return uuid.UUID(bytes=random_uuid())

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2721c639/proton-c/bindings/python/proton/handlers.py
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2721c639/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --cc proton-c/bindings/python/proton/reactor.py
index b475333,a7b0717..c66334b
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@@ -488,9 -489,13 +496,13 @@@ class Connector(Handler)
      def _connect(self, connection):
          url = self.address.next()
          # IoHandler uses the hostname to determine where to try to connect to
 -        connection.hostname = "%s:%i" % (url.host, url.port)
 +        connection.hostname = "%s:%s" % (url.host, url.port)
          logging.info("connecting to %s..." % connection.hostname)
  
+         if url.username:
+             connection.user = url.username
+         if url.password:
+             connection.password = url.password
          transport = Transport()
          transport.bind(connection)
          if self.heartbeat:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2721c639/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --cc tests/python/proton_tests/common.py
index 4f23c13,83a39f8..8bb3609
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@@ -244,12 -225,16 +246,18 @@@ class MessengerApp(object)
                      del cmd[0:1]
                      cmd.insert(0, foundfile)
                      cmd.insert(0, sys.executable)
 -            self._process = Popen(cmd, stdout=PIPE, stderr=STDOUT, bufsize=4096)
 -        except OSError, e:
 +            self._process = Popen(cmd, stdout=PIPE, stderr=STDOUT,
 +                                  bufsize=4096, universal_newlines=True)
 +        except OSError:
 +            e = sys.exc_info()[1]
              print("ERROR: '%s'" % e)
-             assert False, "Unable to execute command '%s', is it in your PATH?" % cmd[0]
+             msg = "Unable to execute command '%s', is it in your PATH?" % cmd[0]
+ 
+             # NOTE(flaper87): Skip the test if the command is not found.
+             if e.errno == 2:
+               raise Skipped("Skipping test - %s" % msg)
+             assert False, msg
+ 
          self._ready()  # wait for it to initialize
  
      def stop(self):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2721c639/tests/python/proton_tests/engine.py
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2721c639/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --cc tests/python/proton_tests/sasl.py
index ce10882,91b3e69..b214b62
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@@ -16,14 -16,71 +16,74 @@@
  # specific language governing permissions and limitations
  # under the License.
  #
 +from __future__ import absolute_import
  
 -import sys, os, common
 +import sys, os
 +from . import common
+ from string import Template
+ import subprocess
+ 
  from proton import *
 -from common import pump, Skipped
 +from .common import pump, Skipped
 +from proton._compat import str2bin
  
+ from cproton import *
+ 
+ def _sslCertpath(file):
+     """ Return the full path to the certificate,keyfile, etc.
+     """
+     return os.path.join(os.path.dirname(__file__),
+                         "ssl_db/%s" % file)
+ 
+ def _cyrusSetup(conf_dir):
+   """Write out simple SASL config
+   """
+   t = Template("""sasldb_path: ${db}
+ mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
+ """)
+   subprocess.call(args=['rm','-rf',conf_dir])
+   os.mkdir(conf_dir)
+   db = os.path.abspath(os.path.join(conf_dir,'proton.sasldb'))
+   conf = os.path.abspath(os.path.join(conf_dir,'proton.conf'))
+   f = open(conf, 'w')
+   f.write(t.substitute(db=db))
+   f.close()
+ 
+   cmd = Template("echo password | saslpasswd2 -c -p -f ${db} -u proton user").substitute(db=db)
+   subprocess.call(args=cmd, shell=True)
+ 
+ def _testSaslMech(self, mech, clientUser='user@proton', authUser='user@proton', encrypted=False, authenticated=True):
+   self.s1.allowed_mechs(mech)
+   self.c1.open()
+ 
+   pump(self.t1, self.t2, 1024)
+ 
+   if encrypted:
+     assert self.t2.encrypted == encrypted
+     assert self.t1.encrypted == encrypted
+   assert self.t2.authenticated == authenticated
+   assert self.t1.authenticated == authenticated
+   if authenticated:
+     # Server
+     assert self.t2.user == authUser
+     assert self.s2.user == authUser
+     assert self.s2.mech == mech.strip()
+     assert self.s2.outcome == SASL.OK
+     # Client
+     assert self.t1.user == clientUser
+     assert self.s1.user == clientUser
+     assert self.s1.mech == mech.strip()
+     assert self.s1.outcome == SASL.OK
+   else:
+     # Server
+     assert self.t2.user == None
+     assert self.s2.user == None
+     assert self.s2.outcome != SASL.OK
+     # Client
+     assert self.t1.user == clientUser
+     assert self.s1.user == clientUser
+     assert self.s1.outcome != SASL.OK
+ 
  class Test(common.Test):
    pass
  

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2721c639/tests/python/proton_tests/ssl.py
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2721c639/tests/python/proton_tests/transport.py
----------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[26/34] qpid-proton git commit: Merge branch 'master' into kgiusti-python3

Posted by kg...@apache.org.
Merge branch 'master' into kgiusti-python3

Conflicts:
	proton-c/bindings/python/setup.py
	tests/python/proton_tests/sasl.py


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

Branch: refs/heads/master
Commit: 0d1da5cf90425edce70663f49e4cb31220d65977
Parents: d09e93e 5b611b7
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Jun 17 15:25:57 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Jun 17 15:25:57 2015 -0400

----------------------------------------------------------------------
 proton-c/CMakeLists.txt                      |  2 +-
 proton-c/bindings/python/setup.py            | 58 +++++++++++++++++++++--
 proton-c/bindings/python/setuputils/misc.py  |  1 +
 proton-c/bindings/ruby/lib/core/ssl.rb       | 18 ++++---
 proton-c/bindings/ruby/lib/core/transport.rb |  5 +-
 proton-c/bindings/ruby/ruby.i                | 13 +----
 proton-c/src/sasl/sasl-internal.h            |  2 +-
 proton-c/src/sasl/sasl.c                     | 11 +++--
 proton-c/src/windows/schannel.c              | 53 ++++++++++++++++-----
 tests/python/proton_tests/common.py          | 28 ++++++++++-
 tests/python/proton_tests/sasl.py            | 40 ----------------
 11 files changed, 147 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0d1da5cf/proton-c/bindings/python/setup.py
----------------------------------------------------------------------
diff --cc proton-c/bindings/python/setup.py
index 1738a14,0a77872..1620b38
--- a/proton-c/bindings/python/setup.py
+++ b/proton-c/bindings/python/setup.py
@@@ -97,8 -117,22 +117,23 @@@ class Configure(build_ext)
          else:
              return compiler.compiler_type
  
+     def prepare_swig_wrap(self):
+         ext = self.distribution.ext_modules[-1]
+ 
+         try:
+             # This will actually call swig to generate the files
+             # and list the sources.
+             self.swig_sources(ext.sources, ext)
+         except (errors.DistutilsExecError, errors.DistutilsPlatformError) as e:
+             if not (os.path.exists('cproton_wrap.c') or
+                     os.path.exists('cproton.py')):
+                 raise e
+ 
+         ext.sources = ext.sources[1:]
+         ext.swig_opts = []
+ 
      def bundle_libqpid_proton_extension(self):
 +        setup_path = os.path.dirname(os.path.realpath(__file__))
          base = self.get_finalized_command('build').build_base
          build_include = os.path.join(base, 'include')
          install = self.get_finalized_command('install').install_base

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0d1da5cf/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --cc tests/python/proton_tests/common.py
index 8bb3609,11bea85..857cb50
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@@ -26,28 -26,8 +26,29 @@@ import sys, os, string, subproces
  from proton import Connection, Transport, SASL, Endpoint, Delivery, SSL
  from proton.reactor import Container
  from proton.handlers import CHandshaker, CFlowController
+ from string import Template
  
 +if sys.version_info[0] == 2 and sys.version_info[1] < 6:
 +    # this is for compatibility, apparently the version of jython we
 +    # use doesn't have the next() builtin.
 +    # we should remove this when we upgrade to a python 2.6+ compatible version
 +    # of jython
 +    #_DEF = object()  This causes the test loader to fail (why?)
 +    class _dummy(): pass
 +    _DEF = _dummy
 +
 +    def next(iter, default=_DEF):
 +        try:
 +            return iter.next()
 +        except StopIteration:
 +            if default is _DEF:
 +                raise
 +            else:
 +                return default
 +    # I may goto hell for this:
 +    import __builtin__
 +    __builtin__.__dict__['next'] = next
 +
  
  def free_tcp_ports(count=1):
    """ return a list of 'count' TCP ports that are free to used (ie. unbound)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0d1da5cf/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --cc tests/python/proton_tests/sasl.py
index b4e9c7a,7f1e7ad..b5d30ab
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@@ -16,16 -16,13 +16,14 @@@
  # specific language governing permissions and limitations
  # under the License.
  #
 +from __future__ import absolute_import
  
 -import sys, os, common
 +import sys, os
 +from . import common
- from string import Template
- import subprocess
  
  from proton import *
 -from common import pump, Skipped
 -
 -from cproton import *
 +from .common import pump, Skipped
 +from proton._compat import str2bin
  
  def _sslCertpath(file):
      """ Return the full path to the certificate,keyfile, etc.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[06/34] qpid-proton git commit: PROTON-490: run the "futurize" tool on all python source files

Posted by kg...@apache.org.
PROTON-490: run the "futurize" tool on all python source files

The futurize tool attempts to forward-port python2.5+ sources to be
compatible with python3.  See http://python-future.org for details.


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

Branch: refs/heads/master
Commit: 903c7246974f89857c0577a80a08603c2b8162e6
Parents: a977f93
Author: Ken Giusti <kg...@apache.org>
Authored: Thu Apr 16 14:01:16 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Apr 22 10:42:59 2015 -0400

----------------------------------------------------------------------
 examples/python/abstract_server.py             |  3 +-
 examples/python/client.py                      |  3 +-
 examples/python/client_http.py                 |  3 +-
 examples/python/db_ctrl.py                     |  7 +-
 examples/python/db_recv.py                     |  3 +-
 examples/python/db_send.py                     | 11 +--
 examples/python/direct_recv.py                 |  3 +-
 examples/python/direct_send.py                 |  3 +-
 examples/python/helloworld.py                  |  3 +-
 examples/python/helloworld_blocking.py         |  3 +-
 examples/python/helloworld_direct.py           |  3 +-
 examples/python/helloworld_direct_tornado.py   |  3 +-
 examples/python/helloworld_tornado.py          |  3 +-
 examples/python/messenger/async.py             |  3 +-
 examples/python/messenger/client.py            |  7 +-
 examples/python/messenger/recv.py              |  7 +-
 examples/python/messenger/recv_async.py        | 11 +--
 examples/python/messenger/send.py              |  3 +-
 examples/python/messenger/send_async.py        |  9 +-
 examples/python/messenger/server.py            |  5 +-
 examples/python/proton_server.py               |  3 +-
 examples/python/queue_browser.py               |  3 +-
 examples/python/reactor/cat.py                 |  3 +-
 examples/python/reactor/count-randomly.py      |  9 +-
 examples/python/reactor/counter.py             |  7 +-
 examples/python/reactor/delegates.py           |  5 +-
 examples/python/reactor/echo.py                |  5 +-
 examples/python/reactor/global-logger.py       |  9 +-
 examples/python/reactor/goodbye-world.py       |  5 +-
 examples/python/reactor/handlers.py            |  7 +-
 examples/python/reactor/hello-world.py         |  3 +-
 examples/python/reactor/reactor-logger.py      |  7 +-
 examples/python/reactor/recv.py                |  3 +-
 examples/python/reactor/scheduling.py          |  7 +-
 examples/python/reactor/tornado-hello-world.py |  3 +-
 examples/python/reactor/unhandled.py           |  3 +-
 examples/python/recurring_timer.py             |  5 +-
 examples/python/recurring_timer_tornado.py     |  5 +-
 examples/python/selected_recv.py               |  3 +-
 examples/python/server.py                      |  5 +-
 examples/python/server_direct.py               |  7 +-
 examples/python/server_tx.py                   |  5 +-
 examples/python/simple_recv.py                 |  3 +-
 examples/python/simple_send.py                 |  3 +-
 examples/python/sync_client.py                 |  3 +-
 examples/python/tx_recv.py                     |  3 +-
 examples/python/tx_recv_interactive.py         | 11 +--
 examples/python/tx_send.py                     |  3 +-
 proton-c/bindings/python/proton/__init__.py    | 33 ++++----
 proton-c/bindings/python/proton/reactor.py     | 11 +--
 proton-c/bindings/python/proton/utils.py       |  2 +-
 proton-c/mllib/__init__.py                     | 10 ++-
 proton-c/mllib/dom.py                          |  5 +-
 proton-c/mllib/parsers.py                      |  3 +-
 proton-c/mllib/transforms.py                   |  3 +-
 proton-c/src/codec/encodings.h.py              | 17 ++--
 proton-c/src/protocol.h.py                     | 91 +++++++++++----------
 tests/python/proton_tests/codec.py             | 87 ++++++++++----------
 tests/python/proton_tests/common.py            | 24 +++++-
 tests/python/proton_tests/engine.py            |  8 +-
 tests/python/proton_tests/interop.py           | 21 ++---
 tests/python/proton_tests/message.py           |  3 +-
 tests/python/proton_tests/messenger.py         |  9 +-
 tests/python/proton_tests/reactor.py           |  3 +-
 tests/python/proton_tests/sasl.py              |  6 +-
 tests/python/proton_tests/soak.py              |  3 +-
 tests/python/proton_tests/ssl.py               | 11 ++-
 tests/python/proton_tests/transport.py         |  9 +-
 tests/python/proton_tests/url.py               |  3 +-
 tests/smoke/recv.py                            |  3 +-
 tests/smoke/send.py                            |  5 +-
 tests/tools/apps/python/msgr-recv.py           |  1 +
 tests/tools/apps/python/msgr-send.py           |  1 +
 73 files changed, 356 insertions(+), 250 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/abstract_server.py
----------------------------------------------------------------------
diff --git a/examples/python/abstract_server.py b/examples/python/abstract_server.py
index 2d0de32..fed7fb2 100755
--- a/examples/python/abstract_server.py
+++ b/examples/python/abstract_server.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton_server import Server
 
 class Application(Server):
@@ -27,7 +28,7 @@ class Application(Server):
     def on_request(self, request, reply_to):
         response = request.upper()
         self.send(response, reply_to)
-        print "Request from: %s" % reply_to
+        print("Request from: %s" % reply_to)
 
 try:
     Application("localhost:5672", "examples").run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/client.py
----------------------------------------------------------------------
diff --git a/examples/python/client.py b/examples/python/client.py
index a116175..18dc81a 100755
--- a/examples/python/client.py
+++ b/examples/python/client.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton import Message
 from proton.handlers import MessagingHandler
@@ -43,7 +44,7 @@ class Client(MessagingHandler):
             self.next_request()
 
     def on_message(self, event):
-        print "%s => %s" % (self.requests.pop(0), event.message.body)
+        print("%s => %s" % (self.requests.pop(0), event.message.body))
         if self.requests:
             self.next_request()
         else:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/client_http.py
----------------------------------------------------------------------
diff --git a/examples/python/client_http.py b/examples/python/client_http.py
index cd0d63f..bf65639 100755
--- a/examples/python/client_http.py
+++ b/examples/python/client_http.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import tornado.ioloop
 import tornado.web
 from proton import Message
@@ -51,7 +52,7 @@ class Client(MessagingHandler):
     def on_message(self, event):
         if self.sent:
             request, handler = self.sent.pop(0)
-            print "%s => %s" % (request, event.message.body)
+            print("%s => %s" % (request, event.message.body))
             handler(event.message.body)
             self.do_request()
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/db_ctrl.py
----------------------------------------------------------------------
diff --git a/examples/python/db_ctrl.py b/examples/python/db_ctrl.py
index b28e0eb..04770ce 100755
--- a/examples/python/db_ctrl.py
+++ b/examples/python/db_ctrl.py
@@ -18,11 +18,12 @@
 # under the License.
 #
 
+from __future__ import print_function
 import sqlite3
 import sys
 
 if len(sys.argv) < 3:
-    print "Usage: %s [init|insert|list] db" % sys.argv[0]
+    print("Usage: %s [init|insert|list] db" % sys.argv[0])
 else:
     conn = sqlite3.connect(sys.argv[2])
     with conn:
@@ -35,7 +36,7 @@ else:
             cursor.execute("SELECT * FROM records")
             rows = cursor.fetchall()
             for r in rows:
-                print r
+                print(r)
         elif sys.argv[1] == "insert":
             while True:
                 l = sys.stdin.readline()
@@ -43,4 +44,4 @@ else:
                 conn.execute("INSERT INTO records(description) VALUES (?)", (l.rstrip(),))
             conn.commit()
         else:
-            print "Unrecognised command: %s" %  sys.argv[1]
+            print("Unrecognised command: %s" %  sys.argv[1])

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/db_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/db_recv.py b/examples/python/db_recv.py
index d8dd7bc..8c79049 100755
--- a/examples/python/db_recv.py
+++ b/examples/python/db_recv.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton.handlers import MessagingHandler
 from proton.reactor import ApplicationEvent, Container, EventInjector
@@ -58,7 +59,7 @@ class Recv(MessagingHandler):
                 self.received += 1
                 self.last_id = id
                 self.db.insert(id, event.message.body, ApplicationEvent("record_inserted", delivery=event.delivery))
-                print "inserted message %s" % id
+                print("inserted message %s" % id)
             else:
                 self.release(event.delivery)
         else:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/db_send.py
----------------------------------------------------------------------
diff --git a/examples/python/db_send.py b/examples/python/db_send.py
index 6464fa6..99558d5 100755
--- a/examples/python/db_send.py
+++ b/examples/python/db_send.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 import Queue
 import time
@@ -49,7 +50,7 @@ class Send(MessagingHandler):
     def on_records_loaded(self, event):
         if self.records.empty():
             if event.subject == self.load_count:
-                print "Exhausted available data, waiting to recheck..."
+                print("Exhausted available data, waiting to recheck...")
                 # check for new data after 5 seconds
                 self.container.schedule(5, self)
         else:
@@ -57,7 +58,7 @@ class Send(MessagingHandler):
 
     def request_records(self):
         if not self.records.full():
-            print "loading records..."
+            print("loading records...")
             self.load_count += 1
             self.db.load(self.records, event=ApplicationEvent("records_loaded", link=self.sender, subject=self.load_count))
 
@@ -71,13 +72,13 @@ class Send(MessagingHandler):
             id = record['id']
             self.sender.send(Message(id=id, durable=True, body=record['description']), tag=str(id))
             self.sent += 1
-            print "sent message %s" % id
+            print("sent message %s" % id)
         self.request_records()
 
     def on_settled(self, event):
         id = int(event.delivery.tag)
         self.db.delete(id)
-        print "settled message %s" % id
+        print("settled message %s" % id)
         self.confirmed += 1
         if self.confirmed == self.target:
             event.connection.close()
@@ -88,7 +89,7 @@ class Send(MessagingHandler):
         self.sent = self.confirmed
 
     def on_timer_task(self, event):
-        print "Rechecking for data..."
+        print("Rechecking for data...")
         self.request_records()
 
 parser = optparse.OptionParser(usage="usage: %prog [options]",

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/direct_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/direct_recv.py b/examples/python/direct_recv.py
index 92f712c..1c6bf36 100755
--- a/examples/python/direct_recv.py
+++ b/examples/python/direct_recv.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -37,7 +38,7 @@ class Recv(MessagingHandler):
             # ignore duplicate message
             return
         if self.expected == 0 or self.received < self.expected:
-            print event.message.body
+            print(event.message.body)
             self.received += 1
             if self.received == self.expected:
                 event.receiver.close()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/direct_send.py
----------------------------------------------------------------------
diff --git a/examples/python/direct_send.py b/examples/python/direct_send.py
index 0bfad17..f551e1e 100755
--- a/examples/python/direct_send.py
+++ b/examples/python/direct_send.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton import Message
 from proton.handlers import MessagingHandler
@@ -43,7 +44,7 @@ class Send(MessagingHandler):
     def on_accepted(self, event):
         self.confirmed += 1
         if self.confirmed == self.total:
-            print "all messages confirmed"
+            print("all messages confirmed")
             event.connection.close()
             self.acceptor.close()
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/helloworld.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld.py b/examples/python/helloworld.py
index d741f5e..d73a4cb 100755
--- a/examples/python/helloworld.py
+++ b/examples/python/helloworld.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -38,7 +39,7 @@ class HelloWorld(MessagingHandler):
         event.sender.close()
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
         event.connection.close()
 
 Container(HelloWorld("localhost:5672", "examples")).run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/helloworld_blocking.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_blocking.py b/examples/python/helloworld_blocking.py
index 62b6105..049f148 100755
--- a/examples/python/helloworld_blocking.py
+++ b/examples/python/helloworld_blocking.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.utils import BlockingConnection
 from proton.handlers import IncomingMessageHandler
@@ -27,7 +28,7 @@ receiver = conn.create_receiver("examples")
 sender = conn.create_sender("examples")
 sender.send(Message(body=u"Hello World!"));
 msg = receiver.receive(timeout=30)
-print msg.body
+print(msg.body)
 receiver.accept()
 conn.close()
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/helloworld_direct.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_direct.py b/examples/python/helloworld_direct.py
index 2ad78a7..d6374a2 100755
--- a/examples/python/helloworld_direct.py
+++ b/examples/python/helloworld_direct.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -36,7 +37,7 @@ class HelloWorld(MessagingHandler):
         event.sender.close()
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
 
     def on_accepted(self, event):
         event.connection.close()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/helloworld_direct_tornado.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_direct_tornado.py b/examples/python/helloworld_direct_tornado.py
index 2466f80..9ef2ed7 100755
--- a/examples/python/helloworld_direct_tornado.py
+++ b/examples/python/helloworld_direct_tornado.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton_tornado import Container
@@ -36,7 +37,7 @@ class HelloWorld(MessagingHandler):
         event.sender.close()
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
 
     def on_accepted(self, event):
         event.connection.close()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/helloworld_tornado.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_tornado.py b/examples/python/helloworld_tornado.py
index d4b32cf..3cb2ad1 100755
--- a/examples/python/helloworld_tornado.py
+++ b/examples/python/helloworld_tornado.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton_tornado import Container
@@ -38,7 +39,7 @@ class HelloWorld(MessagingHandler):
         event.sender.close()
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
         event.connection.close()
 
 Container(HelloWorld("localhost:5672", "examples")).run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/messenger/async.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/async.py b/examples/python/messenger/async.py
index 14fc4c9..b3f5c45 100755
--- a/examples/python/messenger/async.py
+++ b/examples/python/messenger/async.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys
 from proton import *
 
@@ -72,7 +73,7 @@ class CallbackAdapter:
                 self.messenger.accept(t)
             except:
                 ex = sys.exc_info()[1]
-                print "Exception:", ex
+                print("Exception:", ex)
                 self.messenger.reject(t)
 
     def send(self, message, on_status=None):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/messenger/client.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/client.py b/examples/python/messenger/client.py
index 3146e45..62fc16e 100755
--- a/examples/python/messenger/client.py
+++ b/examples/python/messenger/client.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from proton import *
 
@@ -48,8 +49,8 @@ if opts.reply_to[:2] == "~/":
   mng.recv(1)
   try:
     mng.get(msg)
-    print msg.address, msg.subject
-  except Exception, e:
-    print e
+    print(msg.address, msg.subject)
+  except Exception as e:
+    print(e)
 
 mng.stop()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/messenger/recv.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/recv.py b/examples/python/messenger/recv.py
index e19ddad..5771bd7 100755
--- a/examples/python/messenger/recv.py
+++ b/examples/python/messenger/recv.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from proton import *
 
@@ -46,9 +47,9 @@ while True:
   while mng.incoming:
     try:
       mng.get(msg)
-    except Exception, e:
-      print e
+    except Exception as e:
+      print(e)
     else:
-      print msg.address, msg.subject or "(no subject)", msg.properties, msg.body
+      print(msg.address, msg.subject or "(no subject)", msg.properties, msg.body)
 
 mng.stop()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/messenger/recv_async.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/recv_async.py b/examples/python/messenger/recv_async.py
index ba4f063..b38c31a 100755
--- a/examples/python/messenger/recv_async.py
+++ b/examples/python/messenger/recv_async.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from async import *
 
@@ -31,25 +32,25 @@ if not args:
 class App(CallbackAdapter):
 
     def on_start(self):
-        print "Started"
+        print("Started")
         for a in args:
-            print "Subscribing to:", a
+            print("Subscribing to:", a)
             self.messenger.subscribe(a)
         self.messenger.recv()
 
     def on_recv(self, msg):
-        print "Received:", msg
+        print("Received:", msg)
         if msg.body == "die":
             self.stop()
         if msg.reply_to:
             self.message.clear()
             self.message.address = msg.reply_to
             self.message.body = "Reply for: %s" % msg.body
-            print "Replied:", self.message
+            print("Replied:", self.message)
             self.send(self.message)
 
     def on_stop(self):
-        print "Stopped"
+        print("Stopped")
 
 a = App(Messenger())
 a.run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/messenger/send.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/send.py b/examples/python/messenger/send.py
index 139f6e8..f40e7b1 100755
--- a/examples/python/messenger/send.py
+++ b/examples/python/messenger/send.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from proton import *
 
@@ -39,6 +40,6 @@ for m in args:
   mng.put(msg)
 
 mng.send()
-print "sent:", ", ".join(args)
+print("sent:", ", ".join(args))
 
 mng.stop()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/messenger/send_async.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/send_async.py b/examples/python/messenger/send_async.py
index 304aceb..50f7a68 100755
--- a/examples/python/messenger/send_async.py
+++ b/examples/python/messenger/send_async.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from async import *
 
@@ -33,7 +34,7 @@ if not args:
 class App(CallbackAdapter):
 
     def on_start(self):
-        print "Started"
+        print("Started")
         self.message.clear()
         self.message.address = opts.address
         self.message.reply_to = opts.reply_to
@@ -45,19 +46,19 @@ class App(CallbackAdapter):
             self.messenger.recv()
 
     def on_status(self, status):
-        print "Status:", status
+        print("Status:", status)
         if not opts.reply_to or opts.reply_to[0] != "~":
             args.pop(0)
             if not args: self.stop()
 
     def on_recv(self, msg):
-        print "Received:", msg
+        print("Received:", msg)
         if opts.reply_to and opts.reply_to[0] == "~":
             args.pop(0)
             if not args: self.stop()
 
     def on_stop(self):
-        print "Stopped"
+        print("Stopped")
 
 a = App(Messenger())
 a.run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/messenger/server.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/server.py b/examples/python/messenger/server.py
index 01196be..8c25879 100755
--- a/examples/python/messenger/server.py
+++ b/examples/python/messenger/server.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from proton import *
 
@@ -38,7 +39,7 @@ def dispatch(request, response):
   if request.subject:
     response.subject = "Re: %s" % request.subject
   response.properties = request.properties
-  print "Dispatched %s %s" % (request.subject, request.properties)
+  print("Dispatched %s %s" % (request.subject, request.properties))
 
 msg = Message()
 reply = Message()
@@ -50,7 +51,7 @@ while True:
   if mng.incoming > 0:
     mng.get(msg)
     if msg.reply_to:
-      print msg.reply_to
+      print(msg.reply_to)
       reply.address = msg.reply_to
       reply.correlation_id = msg.correlation_id
       reply.body = msg.body

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/proton_server.py
----------------------------------------------------------------------
diff --git a/examples/python/proton_server.py b/examples/python/proton_server.py
index b92261c..c2520c1 100755
--- a/examples/python/proton_server.py
+++ b/examples/python/proton_server.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -38,7 +39,7 @@ class Server(MessagingHandler):
             self.relay = self.container.create_sender(self.conn, None)
 
     def on_connection_close(self, endpoint, error):
-        if error: print "Closed due to %s" % error
+        if error: print("Closed due to %s" % error)
         self.conn.close()
 
     def run(self):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/queue_browser.py
----------------------------------------------------------------------
diff --git a/examples/python/queue_browser.py b/examples/python/queue_browser.py
index ad4d393..34d2377 100755
--- a/examples/python/queue_browser.py
+++ b/examples/python/queue_browser.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton.reactor import Container, Copy
 from proton.handlers import MessagingHandler
 
@@ -30,7 +31,7 @@ class Recv(MessagingHandler):
         event.container.create_receiver(conn, "examples", options=Copy())
 
     def on_message(self, event):
-        print event.message
+        print(event.message)
         if event.receiver.queued == 0 and event.receiver.drained:
             event.connection.close()
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/cat.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/cat.py b/examples/python/reactor/cat.py
index 57f4515..82ebd27 100755
--- a/examples/python/reactor/cat.py
+++ b/examples/python/reactor/cat.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import sys, os
 from proton.reactor import Reactor
 
@@ -42,7 +43,7 @@ class Echo:
         # to be read, or the end of stream has been reached.
         data = os.read(sel.fileno(), 1024)
         if data:
-            print data,
+            print(data, end=' ')
         else:
             sel.terminate()
             event.reactor.update(sel)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/count-randomly.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/count-randomly.py b/examples/python/reactor/count-randomly.py
index d9a32c6..fb3709a 100755
--- a/examples/python/reactor/count-randomly.py
+++ b/examples/python/reactor/count-randomly.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time, random
 from proton.reactor import Reactor
 
@@ -34,7 +35,7 @@ class Counter:
 
     def on_timer_task(self, event):
         self.count += 1
-        print self.count
+        print(self.count)
         if not self.done():
             event.reactor.schedule(0.25, self)
 
@@ -46,7 +47,7 @@ class Program:
 
     def on_reactor_init(self, event):
         self.start = time.time()
-        print "Hello, World!"
+        print("Hello, World!")
 
         # Save the counter instance in an attribute so we can refer to
         # it later.
@@ -60,12 +61,12 @@ class Program:
 
     def on_timer_task(self, event):
         # keep on shouting until we are done counting
-        print "Yay, %s!" % random.randint(10, 100)
+        print("Yay, %s!" % random.randint(10, 100))
         if not self.counter.done():
             event.reactor.schedule(0.5, self)
 
     def on_reactor_final(self, event):
-        print "Goodbye, World! (after %s long seconds)" % (time.time() - self.start)
+        print("Goodbye, World! (after %s long seconds)" % (time.time() - self.start))
 
 # In hello-world.py we said the reactor exits when there are no more
 # events to process. While this is true, it's not actually complete.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/counter.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/counter.py b/examples/python/reactor/counter.py
index 1ef45f0..7c8167a 100755
--- a/examples/python/reactor/counter.py
+++ b/examples/python/reactor/counter.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
@@ -29,7 +30,7 @@ class Counter:
 
     def on_timer_task(self, event):
         self.count += 1
-        print self.count
+        print(self.count)
         if self.count < self.limit:
             # A recurring task can be acomplished by just scheduling
             # another event.
@@ -39,7 +40,7 @@ class Program:
 
     def on_reactor_init(self, event):
         self.start = time.time()
-        print "Hello, World!"
+        print("Hello, World!")
 
         # Note that unlike the previous scheduling example, we pass in
         # a separate object for the handler. This means that the timer
@@ -48,7 +49,7 @@ class Program:
         event.reactor.schedule(0.25, Counter(10))
 
     def on_reactor_final(self, event):
-        print "Goodbye, World! (after %s long seconds)" % (time.time() - self.start)
+        print("Goodbye, World! (after %s long seconds)" % (time.time() - self.start))
 
 # In hello-world.py we said the reactor exits when there are no more
 # events to process. While this is true, it's not actually complete.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/delegates.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/delegates.py b/examples/python/reactor/delegates.py
index 813ceba..1a8e1e9 100755
--- a/examples/python/reactor/delegates.py
+++ b/examples/python/reactor/delegates.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
@@ -28,12 +29,12 @@ from proton.reactor import Reactor
 class Hello:
 
     def on_reactor_init(self, event):
-        print "Hello, World!"
+        print("Hello, World!")
 
 class Goodbye:
 
     def on_reactor_final(self, event):
-        print "Goodbye, World!"
+        print("Goodbye, World!")
 
 class Program:
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/echo.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/echo.py b/examples/python/reactor/echo.py
index 4675f5d..17529d9 100755
--- a/examples/python/reactor/echo.py
+++ b/examples/python/reactor/echo.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import sys, os
 from proton.reactor import Reactor
 
@@ -42,7 +43,7 @@ class Echo:
         # to be read, or the end of stream has been reached.
         data = os.read(sel.fileno(), 1024)
         if data:
-            print data,
+            print(data, end=' ')
         else:
             sel.terminate()
             event.reactor.update(sel)
@@ -54,7 +55,7 @@ class Program:
         # selectable stays alive until it reads the end of stream
         # marker. This will keep the whole reactor running until we
         # type Control-D.
-        print "Type whatever you want and then use Control-D to exit:"
+        print("Type whatever you want and then use Control-D to exit:")
         event.reactor.selectable(Echo(sys.stdin))
 
 r = Reactor(Program())

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/global-logger.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/global-logger.py b/examples/python/reactor/global-logger.py
index bc3bc56..3cbe11c 100755
--- a/examples/python/reactor/global-logger.py
+++ b/examples/python/reactor/global-logger.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
@@ -30,21 +31,21 @@ from proton.reactor import Reactor
 class Logger:
 
     def on_unhandled(self, name, event):
-        print "LOG:", name, event
+        print("LOG:", name, event)
 
 class Task:
 
     def on_timer_task(self, event):
-        print "Mission accomplished!"
+        print("Mission accomplished!")
 
 class Program:
 
     def on_reactor_init(self, event):
-        print "Hello, World!"
+        print("Hello, World!")
         event.reactor.schedule(0, Task())
 
     def on_reactor_final(self, event):
-        print "Goodbye, World!"
+        print("Goodbye, World!")
 
 r = Reactor(Program())
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/goodbye-world.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/goodbye-world.py b/examples/python/reactor/goodbye-world.py
index 44bcf7c..f251c8a 100755
--- a/examples/python/reactor/goodbye-world.py
+++ b/examples/python/reactor/goodbye-world.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton.reactor import Reactor
 
 # So far the reactive hello-world doesn't look too different from a
@@ -30,7 +31,7 @@ class Program:
 
     # As before we handle the reactor init event.
     def on_reactor_init(self, event):
-        print "Hello, World!"
+        print("Hello, World!")
 
     # In addition to an initial event, the reactor also produces an
     # event when it is about to exit. This may not behave much
@@ -40,7 +41,7 @@ class Program:
     # regardless of what other paths the main logic of our program
     # might take.
     def on_reactor_final(self, event):
-        print "Goodbye, World!"
+        print("Goodbye, World!")
 
 r = Reactor(Program())
 r.run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/handlers.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/handlers.py b/examples/python/reactor/handlers.py
index ed3a94d..ee8d807 100755
--- a/examples/python/reactor/handlers.py
+++ b/examples/python/reactor/handlers.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
@@ -25,12 +26,12 @@ from proton.reactor import Reactor
 class World:
 
     def on_reactor_init(self, event):
-        print "World!"
+        print("World!")
 
 class Goodbye:
 
     def on_reactor_final(self, event):
-        print "Goodbye, World!"
+        print("Goodbye, World!")
 
 class Hello:
 
@@ -42,7 +43,7 @@ class Hello:
 
     # The parent handler always receives the event first.
     def on_reactor_init(self, event):
-        print "Hello",
+        print("Hello", end=' ')
 
 r = Reactor(Hello())
 r.run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/hello-world.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/hello-world.py b/examples/python/reactor/hello-world.py
index c685c73..f1708db 100755
--- a/examples/python/reactor/hello-world.py
+++ b/examples/python/reactor/hello-world.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton.reactor import Reactor
 
 # The proton reactor provides a general purpose event processing
@@ -31,7 +32,7 @@ class Program:
     # The reactor init event is produced by the reactor itself when it
     # starts.
     def on_reactor_init(self, event):
-        print "Hello, World!"
+        print("Hello, World!")
 
 # When you construct a reactor, you give it a handler.
 r = Reactor(Program())

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/reactor-logger.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/reactor-logger.py b/examples/python/reactor/reactor-logger.py
index c07e9b9..2d3f9de 100755
--- a/examples/python/reactor/reactor-logger.py
+++ b/examples/python/reactor/reactor-logger.py
@@ -18,21 +18,22 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
 class Logger:
 
     def on_unhandled(self, name, event):
-        print "LOG:", name, event
+        print("LOG:", name, event)
 
 class Program:
 
     def on_reactor_init(self, event):
-        print "Hello, World!"
+        print("Hello, World!")
 
     def on_reactor_final(self, event):
-        print "Goodbye, World!"
+        print("Goodbye, World!")
 
 # You can pass multiple handlers to a reactor when you construct it.
 # Each of these handlers will see every event the reactor sees. By

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/recv.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/recv.py b/examples/python/reactor/recv.py
index aa56472..c6f07f1 100755
--- a/examples/python/reactor/recv.py
+++ b/examples/python/reactor/recv.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.reactor import Reactor
 from proton.handlers import CHandshaker, CFlowController
@@ -41,7 +42,7 @@ class Program:
         # compliment the similar thing on send
         rcv = event.receiver
         if rcv and self.message.recv(rcv):
-            print self.message
+            print(self.message)
             event.delivery.settle()
 
 r = Reactor(Program())

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/scheduling.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/scheduling.py b/examples/python/reactor/scheduling.py
index f822f68..8956821 100755
--- a/examples/python/reactor/scheduling.py
+++ b/examples/python/reactor/scheduling.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
@@ -25,7 +26,7 @@ class Program:
 
     def on_reactor_init(self, event):
         self.start = time.time()
-        print "Hello, World!"
+        print("Hello, World!")
 
         # We can schedule a task event for some point in the future.
         # This will cause the reactor to stick around until it has a
@@ -42,10 +43,10 @@ class Program:
 
     def on_timer_task(self, event):
         task = event.context # xxx: don't have a task property on event yet
-        print task.something_to_say, "my task is complete!"
+        print(task.something_to_say, "my task is complete!")
 
     def on_reactor_final(self, event):
-        print "Goodbye, World! (after %s long seconds)" % (time.time() - self.start)
+        print("Goodbye, World! (after %s long seconds)" % (time.time() - self.start))
 
 r = Reactor(Program())
 r.run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/tornado-hello-world.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/tornado-hello-world.py b/examples/python/reactor/tornado-hello-world.py
index fa8ca83..d06cd1b 100755
--- a/examples/python/reactor/tornado-hello-world.py
+++ b/examples/python/reactor/tornado-hello-world.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import tornado.ioloop
 from tornado_app import TornadoApp
 
@@ -32,7 +33,7 @@ class Program:
     # The reactor init event is produced by the reactor itself when it
     # starts.
     def on_reactor_init(self, event):
-        print "Hello, World!"
+        print("Hello, World!")
 
 # The TornadoApp integrates a Reactor into tornado's ioloop.
 TornadoApp(Program())

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/reactor/unhandled.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/unhandled.py b/examples/python/reactor/unhandled.py
index 3734a71..9ab2212 100755
--- a/examples/python/reactor/unhandled.py
+++ b/examples/python/reactor/unhandled.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
@@ -28,7 +29,7 @@ class Program:
     # if it exists. This can be useful not only for debugging, but for
     # logging and for delegating/inheritance.
     def on_unhandled(self, name, event):
-        print name, event
+        print(name, event)
 
 r = Reactor(Program())
 r.run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/recurring_timer.py
----------------------------------------------------------------------
diff --git a/examples/python/recurring_timer.py b/examples/python/recurring_timer.py
index a39791d..b59dbe1 100755
--- a/examples/python/recurring_timer.py
+++ b/examples/python/recurring_timer.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton.reactor import Container, Handler
 
 class Recurring(Handler):
@@ -29,7 +30,7 @@ class Recurring(Handler):
         self.container.schedule(self.period, self)
 
     def on_timer_task(self, event):
-        print "Tick..."
+        print("Tick...")
         self.container.schedule(self.period, self)
 
 try:
@@ -37,6 +38,6 @@ try:
     container.run()
 except KeyboardInterrupt:
     container.stop()
-    print
+    print()
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/recurring_timer_tornado.py
----------------------------------------------------------------------
diff --git a/examples/python/recurring_timer_tornado.py b/examples/python/recurring_timer_tornado.py
index 1f1c0e7..07ebd26 100755
--- a/examples/python/recurring_timer_tornado.py
+++ b/examples/python/recurring_timer_tornado.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Handler
 from proton_tornado import TornadoLoop
@@ -31,7 +32,7 @@ class Recurring(Handler):
         self.container.schedule(time.time() + self.period, subject=self)
 
     def on_timer(self, event):
-        print "Tick..."
+        print("Tick...")
         self.container.schedule(time.time() + self.period, subject=self)
 
 try:
@@ -39,6 +40,6 @@ try:
     container.run()
 except KeyboardInterrupt:
     container.stop()
-    print
+    print()
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/selected_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/selected_recv.py b/examples/python/selected_recv.py
index 351d4ef..2ea704b 100755
--- a/examples/python/selected_recv.py
+++ b/examples/python/selected_recv.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton.reactor import Container, Selector
 from proton.handlers import MessagingHandler
 
@@ -30,7 +31,7 @@ class Recv(MessagingHandler):
         event.container.create_receiver(conn, "examples", options=Selector(u"colour = 'green'"))
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
 
 try:
     Container(Recv()).run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/server.py
----------------------------------------------------------------------
diff --git a/examples/python/server.py b/examples/python/server.py
index 62aa162..3b0a085 100755
--- a/examples/python/server.py
+++ b/examples/python/server.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -30,7 +31,7 @@ class Server(MessagingHandler):
         self.senders = {}
 
     def on_start(self, event):
-        print "Listening on", self.url
+        print("Listening on", self.url)
         self.container = event.container
         self.conn = event.container.connect(self.url)
         self.receiver = event.container.create_receiver(self.conn, self.address)
@@ -41,7 +42,7 @@ class Server(MessagingHandler):
             self.relay = self.container.create_sender(self.conn, None)
 
     def on_message(self, event):
-        print "Received", event.message
+        print("Received", event.message)
         sender = self.relay or self.senders.get(event.message.reply_to)
         if not sender:
             sender = self.container.create_sender(self.conn, event.message.reply_to)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/server_direct.py
----------------------------------------------------------------------
diff --git a/examples/python/server_direct.py b/examples/python/server_direct.py
index 18a20f3..a9910f1 100755
--- a/examples/python/server_direct.py
+++ b/examples/python/server_direct.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import generate_uuid, Message
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -29,7 +30,7 @@ class Server(MessagingHandler):
         self.senders = {}
 
     def on_start(self, event):
-        print "Listening on", self.url
+        print("Listening on", self.url)
         self.container = event.container
         self.acceptor = event.container.listen(self.url)
 
@@ -47,10 +48,10 @@ class Server(MessagingHandler):
             event.link.target.address = event.link.remote_target.address
 
     def on_message(self, event):
-        print "Received", event.message
+        print("Received", event.message)
         sender = self.senders.get(event.message.reply_to)
         if not sender:
-            print "No link for reply"
+            print("No link for reply")
             return
         sender.send(Message(address=event.message.reply_to, body=event.message.body.upper(),
                             correlation_id=event.message.correlation_id))

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/server_tx.py
----------------------------------------------------------------------
diff --git a/examples/python/server_tx.py b/examples/python/server_tx.py
index 96b83cb..51e734c 100755
--- a/examples/python/server_tx.py
+++ b/examples/python/server_tx.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.reactor import Container
 from proton.handlers import MessagingHandler, TransactionHandler
@@ -35,10 +36,10 @@ class TxRequest(TransactionHandler):
         event.transaction.commit()
 
     def on_transaction_committed(self, event):
-        print "Request processed successfully"
+        print("Request processed successfully")
 
     def on_transaction_aborted(self, event):
-        print "Request processing aborted"
+        print("Request processing aborted")
 
 
 class TxServer(MessagingHandler):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/simple_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/simple_recv.py b/examples/python/simple_recv.py
index abe30cd..5322500 100755
--- a/examples/python/simple_recv.py
+++ b/examples/python/simple_recv.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -37,7 +38,7 @@ class Recv(MessagingHandler):
             # ignore duplicate message
             return
         if self.expected == 0 or self.received < self.expected:
-            print event.message.body
+            print(event.message.body)
             self.received += 1
             if self.received == self.expected:
                 event.receiver.close()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/simple_send.py
----------------------------------------------------------------------
diff --git a/examples/python/simple_send.py b/examples/python/simple_send.py
index 4158272..75ab550 100755
--- a/examples/python/simple_send.py
+++ b/examples/python/simple_send.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton import Message
 from proton.handlers import MessagingHandler
@@ -43,7 +44,7 @@ class Send(MessagingHandler):
     def on_accepted(self, event):
         self.confirmed += 1
         if self.confirmed == self.total:
-            print "all messages confirmed"
+            print("all messages confirmed")
             event.connection.close()
 
     def on_disconnected(self, event):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/sync_client.py
----------------------------------------------------------------------
diff --git a/examples/python/sync_client.py b/examples/python/sync_client.py
index 82cd85f..95a5650 100755
--- a/examples/python/sync_client.py
+++ b/examples/python/sync_client.py
@@ -23,6 +23,7 @@ Demonstrates the client side of the synchronous request-response pattern
 (also known as RPC or Remote Procecure Call) using proton.
 
 """
+from __future__ import print_function
 
 import optparse
 from proton import Message, Url, ConnectionException, Timeout
@@ -48,7 +49,7 @@ try:
                "And the mome raths outgrabe."]
     for request in REQUESTS:
         response = client.call(Message(body=request))
-        print "%s => %s" % (request, response.body)
+        print("%s => %s" % (request, response.body))
 finally:
     client.connection.close()
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/tx_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/tx_recv.py b/examples/python/tx_recv.py
index 641f0a2..4baddcf 100755
--- a/examples/python/tx_recv.py
+++ b/examples/python/tx_recv.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton import Url
 from proton.reactor import Container
@@ -40,7 +41,7 @@ class TxRecv(MessagingHandler, TransactionHandler):
         self.transaction = None
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
         self.transaction.accept(event.delivery)
         self.current_batch += 1
         if self.current_batch == self.batch_size:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/tx_recv_interactive.py
----------------------------------------------------------------------
diff --git a/examples/python/tx_recv_interactive.py b/examples/python/tx_recv_interactive.py
index d08ff2b..2c1d9a7 100755
--- a/examples/python/tx_recv_interactive.py
+++ b/examples/python/tx_recv_interactive.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import sys
 import threading
 from proton.reactor import ApplicationEvent, Container
@@ -35,19 +36,19 @@ class TxRecv(MessagingHandler, TransactionHandler):
         self.transaction = None
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
         self.transaction.accept(event.delivery)
 
     def on_transaction_declared(self, event):
         self.transaction = event.transaction
-        print "transaction declared"
+        print("transaction declared")
 
     def on_transaction_committed(self, event):
-        print "transaction committed"
+        print("transaction committed")
         self.container.declare_transaction(self.conn, handler=self)
 
     def on_transaction_aborted(self, event):
-        print "transaction aborted"
+        print("transaction aborted")
         self.container.declare_transaction(self.conn, handler=self)
 
     def on_commit(self, event):
@@ -71,7 +72,7 @@ try:
     thread.daemon=True
     thread.start()
 
-    print "Enter 'fetch', 'commit' or 'abort'"
+    print("Enter 'fetch', 'commit' or 'abort'")
     while True:
         line = sys.stdin.readline()
         if line:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/examples/python/tx_send.py
----------------------------------------------------------------------
diff --git a/examples/python/tx_send.py b/examples/python/tx_send.py
index 0f1da5a..5e30174 100755
--- a/examples/python/tx_send.py
+++ b/examples/python/tx_send.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton import Message, Url
 from proton.reactor import Container
@@ -64,7 +65,7 @@ class TxSend(MessagingHandler, TransactionHandler):
     def on_transaction_committed(self, event):
         self.committed += self.current_batch
         if self.committed == self.total:
-            print "all messages committed"
+            print("all messages committed")
             event.connection.close()
         else:
             self.current_batch = 0

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
index 8a9d857..cf73a53 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -29,9 +29,10 @@ The proton APIs consist of the following classes:
                   data.
 
 """
+from __future__ import absolute_import
 
 from cproton import *
-from wrapper import Wrapper
+from .wrapper import Wrapper
 
 import weakref, socket, sys, threading
 try:
@@ -831,19 +832,19 @@ class Message(object):
     props = Data(pn_message_properties(self._msg))
     body = Data(pn_message_body(self._msg))
 
-    if inst.next():
+    if next(inst):
       self.instructions = inst.get_object()
     else:
       self.instructions = None
-    if ann.next():
+    if next(ann):
       self.annotations = ann.get_object()
     else:
       self.annotations = None
-    if props.next():
+    if next(props):
       self.properties = props.get_object()
     else:
       self.properties = None
-    if body.next():
+    if next(body):
       self.body = body.get_object()
     else:
       self.body = None
@@ -2049,9 +2050,9 @@ class Data:
     if self.enter():
       try:
         result = {}
-        while self.next():
+        while next(self):
           k = self.get_object()
-          if self.next():
+          if next(self):
             v = self.get_object()
           else:
             v = None
@@ -2073,7 +2074,7 @@ class Data:
     if self.enter():
       try:
         result = []
-        while self.next():
+        while next(self):
           result.append(self.get_object())
       finally:
         self.exit()
@@ -2082,9 +2083,9 @@ class Data:
   def get_py_described(self):
     if self.enter():
       try:
-        self.next()
+        next(self)
         descriptor = self.get_object()
-        self.next()
+        next(self)
         value = self.get_object()
       finally:
         self.exit()
@@ -2111,12 +2112,12 @@ class Data:
     if self.enter():
       try:
         if described:
-          self.next()
+          next(self)
           descriptor = self.get_object()
         else:
           descriptor = UNDESCRIBED
         elements = []
-        while self.next():
+        while next(self):
           elements.append(self.get_object())
       finally:
         self.exit()
@@ -2225,7 +2226,7 @@ class Endpoint(object):
       assert False, "Subclass must override this!"
 
   def _get_handler(self):
-    import reactor
+    from . import reactor
     ractor = reactor.Reactor.wrap(pn_object_reactor(self._impl))
     if ractor:
       on_error = ractor.on_error
@@ -2235,7 +2236,7 @@ class Endpoint(object):
     return WrappedHandler.wrap(pn_record_get_handler(record), on_error)
 
   def _set_handler(self, handler):
-    import reactor
+    from . import reactor
     ractor = reactor.Reactor.wrap(pn_object_reactor(self._impl))
     if ractor:
       on_error = ractor.on_error
@@ -2291,7 +2292,7 @@ def dat2obj(dimpl):
   if dimpl:
     d = Data(dimpl)
     d.rewind()
-    d.next()
+    next(d)
     obj = d.get_object()
     d.rewind()
     return obj
@@ -2883,7 +2884,7 @@ class Sender(Link):
           yield str(count)
           count += 1
       self.tag_generator = simple_tags()
-    return self.tag_generator.next()
+    return next(self.tag_generator)
 
 class Receiver(Link):
   """

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index 467bb76..03d8af3 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -28,7 +29,7 @@ from proton import unicode2utf8, utf82unicode
 
 import traceback
 from proton import WrappedHandler, _chandler, secs2millis, millis2secs, timeout2millis, millis2timeout, Selectable
-from wrapper import Wrapper, PYCTX
+from .wrapper import Wrapper, PYCTX
 from cproton import *
 
 class Task(Wrapper):
@@ -479,7 +480,7 @@ class Connector(Handler):
         self.ssl_domain = None
 
     def _connect(self, connection):
-        url = self.address.next()
+        url = next(self.address)
         # IoHandler uses the hostname to determine where to try to connect to
         connection.hostname = "%s:%i" % (url.host, url.port)
         logging.info("connecting to %s..." % connection.hostname)
@@ -514,7 +515,7 @@ class Connector(Handler):
         if self.connection and self.connection.state & Endpoint.LOCAL_ACTIVE:
             if self.reconnect:
                 event.transport.unbind()
-                delay = self.reconnect.next()
+                delay = next(self.reconnect)
                 if delay == 0:
                     logging.info("Disconnected, reconnecting...")
                     self._connect(self.connection)
@@ -560,10 +561,10 @@ class Urls(object):
 
     def next(self):
         try:
-            return self.i.next()
+            return next(self.i)
         except StopIteration:
             self.i = iter(self.values)
-            return self.i.next()
+            return next(self.i)
 
 class SSLConfig(object):
     def __init__(self):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/proton-c/bindings/python/proton/utils.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/utils.py b/proton-c/bindings/python/proton/utils.py
index b5ecdf7..cb65fda 100644
--- a/proton-c/bindings/python/proton/utils.py
+++ b/proton-c/bindings/python/proton/utils.py
@@ -312,7 +312,7 @@ class SyncRequestResponse(IncomingMessageHandler):
         if not self.address and not request.address:
             raise ValueError("Request message has no address: %s" % request)
         request.reply_to = self.reply_to
-        request.correlation_id = correlation_id = self.correlation_id.next()
+        request.correlation_id = correlation_id = next(self.correlation_id)
         self.sender.send(request)
         def wakeup():
             return self.response and (self.response.correlation_id == correlation_id)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/proton-c/mllib/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/__init__.py b/proton-c/mllib/__init__.py
index 9aa1e56..c6fccf1 100644
--- a/proton-c/mllib/__init__.py
+++ b/proton-c/mllib/__init__.py
@@ -22,16 +22,22 @@ This module provides document parsing and transformation utilities for
 both SGML and XML.
 """
 
-import os, dom, transforms, parsers, sys
+from __future__ import absolute_import
+
+import os, sys
 import xml.sax, types
 from xml.sax.handler import ErrorHandler
 from xml.sax.xmlreader import InputSource
 from cStringIO import StringIO
 
+from . import dom
+from . import transforms
+from . import parsers
+
 def transform(node, *args):
   result = node
   for t in args:
-    if isinstance(t, types.ClassType):
+    if isinstance(t, type):
       t = t()
     result = result.dispatch(t)
   return result

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/proton-c/mllib/dom.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/dom.py b/proton-c/mllib/dom.py
index 486f708..4cbac26 100644
--- a/proton-c/mllib/dom.py
+++ b/proton-c/mllib/dom.py
@@ -24,8 +24,8 @@ Simple DOM for both SGML and XML documents.
 from __future__ import division
 from __future__ import generators
 from __future__ import nested_scopes
+from __future__ import absolute_import
 
-import transforms
 
 class Container:
 
@@ -109,6 +109,7 @@ class Node(Container, Component, Dispatcher):
       return nd
 
   def text(self):
+    from . import transforms
     return self.dispatch(transforms.Text())
 
   def tag(self, name, *attrs, **kwargs):
@@ -238,7 +239,7 @@ class Flatten(View):
     sources = [iter(self.source)]
     while sources:
       try:
-        nd = sources[-1].next()
+        nd = next(sources[-1])
         if isinstance(nd, Tree):
           sources.append(iter(nd.children))
         else:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/proton-c/mllib/parsers.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/parsers.py b/proton-c/mllib/parsers.py
index 3e7cc10..e71018d 100644
--- a/proton-c/mllib/parsers.py
+++ b/proton-c/mllib/parsers.py
@@ -20,9 +20,10 @@
 """
 Parsers for SGML and XML to dom.
 """
+from __future__ import absolute_import
 
 import sgmllib, xml.sax.handler
-from dom import *
+from .dom import *
 
 class Parser:
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/proton-c/mllib/transforms.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/transforms.py b/proton-c/mllib/transforms.py
index 69d9912..383add3 100644
--- a/proton-c/mllib/transforms.py
+++ b/proton-c/mllib/transforms.py
@@ -20,8 +20,9 @@
 """
 Useful transforms for dom objects.
 """
+from __future__ import absolute_import
 
-import dom
+from . import dom
 from cStringIO import StringIO
 
 class Visitor:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/proton-c/src/codec/encodings.h.py
----------------------------------------------------------------------
diff --git a/proton-c/src/codec/encodings.h.py b/proton-c/src/codec/encodings.h.py
index 71fb9ea..9f08c6c 100755
--- a/proton-c/src/codec/encodings.h.py
+++ b/proton-c/src/codec/encodings.h.py
@@ -18,16 +18,17 @@
 # under the License.
 #
 
+from __future__ import print_function
 import mllib, optparse, os, sys
 
 xml = os.path.join(os.path.dirname(__file__), "types.xml")
 doc = mllib.xml_parse(xml)
 
-print "/* generated from %s */" % xml
-print "#ifndef _PROTON_ENCODINGS_H"
-print "#define _PROTON_ENCODINGS_H 1"
-print
-print "#define PNE_DESCRIPTOR          (0x00)"
+print("/* generated from %s */" % xml)
+print("#ifndef _PROTON_ENCODINGS_H")
+print("#define _PROTON_ENCODINGS_H 1")
+print()
+print("#define PNE_DESCRIPTOR          (0x00)")
 
 for enc in doc.query["amqp/section/type/encoding"]:
   name = enc["@name"] or enc.parent["@name"]
@@ -35,7 +36,7 @@ for enc in doc.query["amqp/section/type/encoding"]:
   if name == "ieee-754":
     name = enc.parent["@name"]
   cname = "PNE_" + name.replace("-", "_").upper()
-  print "#define %s%s(%s)" % (cname, " "*(20-len(cname)), enc["@code"])
+  print("#define %s%s(%s)" % (cname, " "*(20-len(cname)), enc["@code"]))
 
-print
-print "#endif /* encodings.h */"
+print()
+print("#endif /* encodings.h */")

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/proton-c/src/protocol.h.py
----------------------------------------------------------------------
diff --git a/proton-c/src/protocol.h.py b/proton-c/src/protocol.h.py
index 76a2391..bbc0dfe 100644
--- a/proton-c/src/protocol.h.py
+++ b/proton-c/src/protocol.h.py
@@ -18,20 +18,21 @@
 # under the License.
 #
 
+from __future__ import print_function
 from protocol import *
 
-print "/* generated */"
-print "#ifndef _PROTON_PROTOCOL_H"
-print "#define _PROTON_PROTOCOL_H 1"
-print
-print "#include \"proton/type_compat.h\""
+print("/* generated */")
+print("#ifndef _PROTON_PROTOCOL_H")
+print("#define _PROTON_PROTOCOL_H 1")
+print()
+print("#include \"proton/type_compat.h\"")
 
 fields = {}
 
 for type in TYPES:
   fidx = 0
   for f in type.query["field"]:
-    print "#define %s_%s (%s)" % (field_kw(type), field_kw(f), fidx)
+    print("#define %s_%s (%s)" % (field_kw(type), field_kw(f), fidx))
     fidx += 1
 
 idx = 0
@@ -39,14 +40,14 @@ idx = 0
 for type in TYPES:
   desc = type["descriptor"]
   name = type["@name"].upper().replace("-", "_")
-  print "#define %s_SYM (\"%s\")" % (name, desc["@name"])
+  print("#define %s_SYM (\"%s\")" % (name, desc["@name"]))
   hi, lo = [int(x, 0) for x in desc["@code"].split(":")]
   code = (hi << 32) + lo
-  print "#define %s ((uint64_t) %s)" % (name, code)
+  print("#define %s ((uint64_t) %s)" % (name, code))
   fields[code] = (type["@name"], [f["@name"] for f in type.query["field"]])
   idx += 1
 
-print """
+print("""
 #include <stddef.h>
 
 typedef struct {
@@ -61,43 +62,43 @@ extern const uint16_t FIELD_NAME[];
 extern const uint16_t FIELD_FIELDS[];
 extern const unsigned char FIELD_MIN;
 extern const unsigned char FIELD_MAX;
-"""
+""")
 
-print "#ifdef DEFINE_FIELDS"
+print("#ifdef DEFINE_FIELDS")
 
-print 'struct FIELD_STRINGS {'
-print '  const char FIELD_STRINGS_NULL[sizeof("")];'
+print('struct FIELD_STRINGS {')
+print('  const char FIELD_STRINGS_NULL[sizeof("")];')
 strings = set()
 for name, fnames in fields.values():
     strings.add(name)
     strings.update(fnames)
 for str in strings:
     istr = str.replace("-", "_");
-    print '  const char FIELD_STRINGS_%s[sizeof("%s")];' % (istr, str)
-print "};"
-print
-print 'const struct FIELD_STRINGS FIELD_STRINGS = {'
-print '  "",'
+    print('  const char FIELD_STRINGS_%s[sizeof("%s")];' % (istr, str))
+print("};")
+print()
+print('const struct FIELD_STRINGS FIELD_STRINGS = {')
+print('  "",')
 for str in strings:
-    print '  "%s",'% str
-print "};"
-print 'const char * const FIELD_STRINGPOOL = (const char * const) &FIELD_STRINGS;'
-print
-print "/* This is an array of offsets into FIELD_STRINGPOOL */"
-print "const uint16_t FIELD_NAME[] = {"
-print "  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_NULL),"
+    print('  "%s",'% str)
+print("};")
+print('const char * const FIELD_STRINGPOOL = (const char * const) &FIELD_STRINGS;')
+print()
+print("/* This is an array of offsets into FIELD_STRINGPOOL */")
+print("const uint16_t FIELD_NAME[] = {")
+print("  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_NULL),")
 index = 1
 for i in range(256):
   if i in fields:
     name, fnames = fields[i]
     iname = name.replace("-", "_");
-    print '  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_%s), /* %d */' % (iname, index)
+    print('  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_%s), /* %d */' % (iname, index))
     index += 1
-print "};"
+print("};")
 
-print "/* This is an array of offsets into FIELD_STRINGPOOL */"
-print "const uint16_t FIELD_FIELDS[] = {"
-print "  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_NULL),"
+print("/* This is an array of offsets into FIELD_STRINGPOOL */")
+print("const uint16_t FIELD_FIELDS[] = {")
+print("  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_NULL),")
 index = 1
 for i in range(256):
   if i in fields:
@@ -105,11 +106,11 @@ for i in range(256):
     if fnames:
       for f in fnames:
         ifname = f.replace("-", "_");
-        print '  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_%s), /* %d (%s) */' % (ifname, index, name)
+        print('  offsetof(struct FIELD_STRINGS, FIELD_STRINGS_%s), /* %d (%s) */' % (ifname, index, name))
         index += 1
-print "};"
+print("};")
 
-print "const pn_fields_t FIELDS[] = {"
+print("const pn_fields_t FIELDS[] = {")
 
 name_count = 1
 field_count = 1
@@ -124,21 +125,21 @@ for i in range(field_min, field_max+1):
   if i in fields:
     name, fnames = fields[i]
     if fnames:
-      print '  {%d, %d, %d}, /* %d (%s) */' % (name_count, field_count, len(fnames), i, name)
+      print('  {%d, %d, %d}, /* %d (%s) */' % (name_count, field_count, len(fnames), i, name))
       field_count += len(fnames)
     else:
-      print '  {%d, 0, 0}, /* %d (%s) */' % (name_count, i, name)
+      print('  {%d, 0, 0}, /* %d (%s) */' % (name_count, i, name))
     name_count += 1
     if i>field_max: field_max = i
     if i<field_min: field_min = i
   else:
-    print '  {0, 0, 0}, /* %d */' % i
-
-print "};"
-print
-print 'const unsigned char FIELD_MIN = %d;' % field_min
-print 'const unsigned char FIELD_MAX = %d;' % field_max
-print
-print "#endif"
-print
-print "#endif /* protocol.h */"
+    print('  {0, 0, 0}, /* %d */' % i)
+
+print("};")
+print()
+print('const unsigned char FIELD_MIN = %d;' % field_min)
+print('const unsigned char FIELD_MAX = %d;' % field_max)
+print()
+print("#endif")
+print()
+print("#endif /* protocol.h */")

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/python/proton_tests/codec.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/codec.py b/tests/python/proton_tests/codec.py
index 81bb4de..e8893cf 100644
--- a/tests/python/proton_tests/codec.py
+++ b/tests/python/proton_tests/codec.py
@@ -17,7 +17,8 @@
 # under the License.
 #
 
-import os, common, sys
+import os, sys
+from . import common
 from proton import *
 try:
   from uuid import uuid4
@@ -36,58 +37,58 @@ class Test(common.Test):
 class DataTest(Test):
 
   def testTopLevelNext(self):
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_null()
     self.data.put_bool(False)
     self.data.put_int(0)
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.rewind()
-    assert self.data.next() == Data.NULL
-    assert self.data.next() == Data.BOOL
-    assert self.data.next() == Data.INT
-    assert self.data.next() is None
+    assert next(self.data) == Data.NULL
+    assert next(self.data) == Data.BOOL
+    assert next(self.data) == Data.INT
+    assert next(self.data) is None
 
   def testNestedNext(self):
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_null()
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_list()
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_bool(False)
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.rewind()
-    assert self.data.next() is Data.NULL
-    assert self.data.next() is Data.LIST
+    assert next(self.data) is Data.NULL
+    assert next(self.data) is Data.LIST
     self.data.enter()
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_ubyte(0)
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_uint(0)
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_int(0)
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.exit()
-    assert self.data.next() is Data.BOOL
-    assert self.data.next() is None
+    assert next(self.data) is Data.BOOL
+    assert next(self.data) is None
 
     self.data.rewind()
-    assert self.data.next() is Data.NULL
-    assert self.data.next() is Data.LIST
+    assert next(self.data) is Data.NULL
+    assert next(self.data) is Data.LIST
     assert self.data.enter()
-    assert self.data.next() is Data.UBYTE
-    assert self.data.next() is Data.UINT
-    assert self.data.next() is Data.INT
-    assert self.data.next() is None
+    assert next(self.data) is Data.UBYTE
+    assert next(self.data) is Data.UINT
+    assert next(self.data) is Data.INT
+    assert next(self.data) is None
     assert self.data.exit()
-    assert self.data.next() is Data.BOOL
-    assert self.data.next() is None
+    assert next(self.data) is Data.BOOL
+    assert next(self.data) is None
 
   def testEnterExit(self):
-    assert self.data.next() is None
+    assert next(self.data) is None
     assert not self.data.enter()
     self.data.put_list()
     assert self.data.enter()
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_list()
     assert self.data.enter()
     self.data.put_list()
@@ -100,19 +101,19 @@ class DataTest(Test):
     assert self.data.get_list() == 1
     assert not self.data.exit()
     assert self.data.get_list() == 1
-    assert self.data.next() is None
+    assert next(self.data) is None
 
     self.data.rewind()
-    assert self.data.next() is Data.LIST
+    assert next(self.data) is Data.LIST
     assert self.data.get_list() == 1
     assert self.data.enter()
-    assert self.data.next() is Data.LIST
+    assert next(self.data) is Data.LIST
     assert self.data.get_list() == 1
     assert self.data.enter()
-    assert self.data.next() is Data.LIST
+    assert next(self.data) is Data.LIST
     assert self.data.get_list() == 0
     assert self.data.enter()
-    assert self.data.next() is None
+    assert next(self.data) is None
     assert self.data.exit()
     assert self.data.get_list() == 0
     assert self.data.exit()
@@ -126,7 +127,7 @@ class DataTest(Test):
     """More informative exception from putters, include bad value"""
     try:
       putter(v)
-    except Exception, e:
+    except Exception:
       etype, value, trace = sys.exc_info()
       raise etype, "%s(%r): %s" % (putter.__name__, v, value), trace
     return putter
@@ -168,7 +169,7 @@ class DataTest(Test):
       self.put(putter, v)
     self.data.exit()
     self.data.rewind()
-    assert self.data.next() == Data.ARRAY
+    assert next(self.data) == Data.ARRAY
     count, described, type = self.data.get_array()
     assert count == len(values), count
     if dtype is None:
@@ -178,17 +179,17 @@ class DataTest(Test):
     assert type == aTYPE, type
     assert self.data.enter()
     if described:
-      assert self.data.next() == dTYPE
+      assert next(self.data) == dTYPE
       getter = getattr(self.data, "get_%s" % dtype)
       gotten = getter()
       assert gotten == descriptor, gotten
     if values:
       getter = getattr(self.data, "get_%s" % atype)
       for v in values:
-        assert self.data.next() == aTYPE
+        assert next(self.data) == aTYPE
         gotten = getter()
         assert gotten == v, gotten
-    assert self.data.next() is None
+    assert next(self.data) is None
     assert self.data.exit()
 
   def testStringArray(self):
@@ -230,7 +231,7 @@ class DataTest(Test):
     self.data.rewind()
 
     for v in values:
-      vtype = self.data.next()
+      vtype = next(self.data)
       assert vtype == ntype, vtype
       gotten = getter()
       assert eq(gotten, v), (gotten, v)
@@ -245,7 +246,7 @@ class DataTest(Test):
     cgetter = getattr(copy, "get_%s" % dtype)
 
     for v in values:
-      vtype = copy.next()
+      vtype = next(copy)
       assert vtype == ntype, vtype
       gotten = cgetter()
       assert eq(gotten, v), (gotten, v)
@@ -345,7 +346,7 @@ class DataTest(Test):
     data = Data()
     data.decode(enc)
     data.rewind()
-    assert data.next()
+    assert next(data)
     copy = data.get_object()
     assert copy == obj, (copy, obj)
 
@@ -355,7 +356,7 @@ class DataTest(Test):
            symbol("list"): [1, 2, 3, 4]}
     self.data.put_object(obj)
     self.data.rewind()
-    self.data.next()
+    next(self.data)
     self.data.enter()
     self.data.narrow()
     assert self.data.lookup("pi")

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py b/tests/python/proton_tests/common.py
index 1b8dbdb..585ea02 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -27,6 +27,27 @@ from proton import Connection, Transport, SASL, Endpoint, Delivery, SSL
 from proton.reactor import Container
 from proton.handlers import CHandshaker, CFlowController
 
+if sys.version_info[0] == 2 and sys.version_info[1] < 6:
+    # this is for compatibility, apparently the version of jython we
+    # use doesn't have the next() builtin.
+    # we should remove this when we upgrade to a python 2.6+ compatible version
+    # of jython
+    #_DEF = object()  This causes the test loader to fail (why?)
+    class _dummy(): pass
+    _DEF = _dummy
+
+    def next(iter, default=_DEF):
+        try:
+            return iter.next()
+        except StopIteration:
+            if default is _DEF:
+                raise
+            else:
+                return default
+    # I may goto hell for this:
+    import __builtin__
+    __builtin__.__dict__['next'] = next
+
 
 def free_tcp_ports(count=1):
   """ return a list of 'count' TCP ports that are free to used (ie. unbound)
@@ -224,7 +245,8 @@ class MessengerApp(object):
                     cmd.insert(0, foundfile)
                     cmd.insert(0, sys.executable)
             self._process = Popen(cmd, stdout=PIPE, stderr=STDOUT, bufsize=4096)
-        except OSError, e:
+        except OSError:
+            e = sys.exc_info()[1]
             print("ERROR: '%s'" % e)
             assert False, "Unable to execute command '%s', is it in your PATH?" % cmd[0]
         self._ready()  # wait for it to initialize

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index 99125d9..7835792 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,10 +18,11 @@
 # under the License.
 #
 
-import os, common, gc
+import os, gc
+from . import common
 from time import time, sleep
 from proton import *
-from common import pump
+from .common import pump
 from proton.reactor import Reactor
 
 # older versions of gc do not provide the garbage list
@@ -1836,7 +1838,7 @@ class PipelineTest(Test):
     assert rcv.queued == 0, rcv.queued
 
 import sys
-from common import Skipped
+from .common import Skipped
 
 class ServerTest(Test):
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/python/proton_tests/interop.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/interop.py b/tests/python/proton_tests/interop.py
index baf998d..1ef92dd 100644
--- a/tests/python/proton_tests/interop.py
+++ b/tests/python/proton_tests/interop.py
@@ -18,7 +18,8 @@
 #
 
 from proton import *
-import os, common
+import os
+from . import common
 
 
 def find_test_interop_dir():
@@ -70,7 +71,7 @@ class InteropTest(common.Test):
         self.decode_data(body)
 
     def assert_next(self, type, value):
-        next_type = self.data.next()
+        next_type = next(self.data)
         assert next_type == type, "Type mismatch: %s != %s"%(
             Data.type_names[next_type], Data.type_names[type])
         next_value = self.data.get_object()
@@ -79,7 +80,7 @@ class InteropTest(common.Test):
     def test_message(self):
         self.decode_message_file("message")
         self.assert_next(Data.STRING, "hello")
-        assert self.data.next() is None
+        assert next(self.data) is None
 
     def test_primitives(self):
         self.decode_data_file("primitives")
@@ -94,7 +95,7 @@ class InteropTest(common.Test):
         self.assert_next(Data.LONG, -12345)
         self.assert_next(Data.FLOAT, 0.125)
         self.assert_next(Data.DOUBLE, 0.125)
-        assert self.data.next() is None
+        assert next(self.data) is None
 
     def test_strings(self):
         self.decode_data_file("strings")
@@ -104,20 +105,20 @@ class InteropTest(common.Test):
         self.assert_next(Data.BINARY, "")
         self.assert_next(Data.STRING, "")
         self.assert_next(Data.SYMBOL, "")
-        assert self.data.next() is None
+        assert next(self.data) is None
 
     def test_described(self):
         self.decode_data_file("described")
         self.assert_next(Data.DESCRIBED, Described("foo-descriptor", "foo-value"))
         self.data.exit()
 
-        assert self.data.next() == Data.DESCRIBED
+        assert next(self.data) == Data.DESCRIBED
         self.data.enter()
         self.assert_next(Data.INT, 12)
         self.assert_next(Data.INT, 13)
         self.data.exit()
 
-        assert self.data.next() is None
+        assert next(self.data) is None
 
     def test_described_array(self):
         self.decode_data_file("described_array")
@@ -128,17 +129,17 @@ class InteropTest(common.Test):
         self.assert_next(Data.ARRAY, Array(UNDESCRIBED, Data.INT, *range(0,100)))
         self.assert_next(Data.ARRAY, Array(UNDESCRIBED, Data.STRING, *["a", "b", "c"]))
         self.assert_next(Data.ARRAY, Array(UNDESCRIBED, Data.INT))
-        assert self.data.next() is None
+        assert next(self.data) is None
 
     def test_lists(self):
         self.decode_data_file("lists")
         self.assert_next(Data.LIST, [32, "foo", True])
         self.assert_next(Data.LIST, [])
-        assert self.data.next() is None
+        assert next(self.data) is None
 
     def test_maps(self):
         self.decode_data_file("maps")
         self.assert_next(Data.MAP, {"one":1, "two":2, "three":3 })
         self.assert_next(Data.MAP, {1:"one", 2:"two", 3:"three"})
         self.assert_next(Data.MAP, {})
-        assert self.data.next() is None
+        assert next(self.data) is None

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/python/proton_tests/message.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/message.py b/tests/python/proton_tests/message.py
index 6bf94fe..3366366 100644
--- a/tests/python/proton_tests/message.py
+++ b/tests/python/proton_tests/message.py
@@ -17,7 +17,8 @@
 # under the License.
 #
 
-import os, common
+import os
+from . import common
 from proton import *
 try:
   from uuid import uuid4

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/python/proton_tests/messenger.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/messenger.py b/tests/python/proton_tests/messenger.py
index c7c7dd3..03a1b6b 100644
--- a/tests/python/proton_tests/messenger.py
+++ b/tests/python/proton_tests/messenger.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,11 +18,12 @@
 # under the License.
 #
 
-import os, common, sys, traceback
+import os, sys, traceback
+from . import common
 from proton import *
 from threading import Thread, Event
 from time import sleep, time
-from common import Skipped
+from .common import Skipped
 
 class Test(common.Test):
 
@@ -180,7 +182,8 @@ class MessengerTest(Test):
     try:
       self.client.put(msg)
       assert False, "Expecting MessengerException"
-    except MessengerException, exc:
+    except MessengerException:
+      exc = sys.exc_info()[1]
       err = str(exc)
       assert "unable to send to address: totally-bogus-address" in err, err
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index 4e660a5..6afee30 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,7 +18,7 @@
 # under the License.
 #
 
-from common import Test
+from .common import Test
 from proton.reactor import Reactor
 
 class Barf(Exception):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index 68fb6e3..4d569bc 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,9 +18,10 @@
 # under the License.
 #
 
-import sys, os, common
+import sys, os
+from . import common
 from proton import *
-from common import pump, Skipped
+from .common import pump, Skipped
 
 class Test(common.Test):
   pass

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/python/proton_tests/soak.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/soak.py b/tests/python/proton_tests/soak.py
index 9e5ceab..0a6e693 100644
--- a/tests/python/proton_tests/soak.py
+++ b/tests/python/proton_tests/soak.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +19,7 @@
 #
 import os
 import sys
-from common import Test, Skipped, free_tcp_ports, \
+from .common import Test, Skipped, free_tcp_ports, \
     MessengerReceiverC, MessengerSenderC, \
     MessengerReceiverValgrind, MessengerSenderValgrind, \
     MessengerReceiverPython, MessengerSenderPython, \

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/903c7246/tests/python/proton_tests/ssl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/ssl.py b/tests/python/proton_tests/ssl.py
index f5fae3f..fd5aaf1 100644
--- a/tests/python/proton_tests/ssl.py
+++ b/tests/python/proton_tests/ssl.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,13 +18,14 @@
 # under the License.
 #
 
-import os, common
+import os
+from . import common
 import random
 import string
 import subprocess
 
 from proton import *
-from common import Skipped, pump
+from .common import Skipped, pump
 
 
 def _testpath(file):
@@ -791,7 +793,7 @@ class SslTest(common.Test):
         try:
             ssl3 = SSL(transport, self.server_domain)
             assert False, "Expected error did not occur!"
-        except SSLException, e:
+        except SSLException:
             pass
 
 class MessengerSSLTests(common.Test):
@@ -834,7 +836,8 @@ class MessengerSSLTests(common.Test):
             self.server.subscribe("amqps://~0.0.0.0:12345")
             if exception is not None:
                 assert False, "expected failure did not occur"
-        except MessengerException, e:
+        except MessengerException:
+            e = sys.exc_info()[1]
             if exception:
                 assert exception in str(e), str(e)
             else:


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[15/34] qpid-proton git commit: PROTON-490: remove dependency on six, provide simple abstractions for language differences

Posted by kg...@apache.org.
PROTON-490: remove dependency on six, provide simple abstractions for language differences


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

Branch: refs/heads/master
Commit: 646ee41cbb1071b60394fd85ec44bc515a19605a
Parents: d31100a
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Apr 29 09:44:31 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Apr 29 09:44:31 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/proton/__init__.py |  26 +-
 proton-c/bindings/python/proton/_compat.py  |  84 +++
 proton-c/bindings/python/proton/handlers.py |   1 -
 proton-c/bindings/python/proton/reactor.py  |  16 +-
 proton-c/bindings/python/proton/utils.py    |   2 -
 proton-c/mllib/__init__.py                  |  17 +-
 proton-c/mllib/dom.py                       |  12 +-
 proton-c/mllib/transforms.py                |   5 +-
 tests/python/proton-test                    |  18 +-
 tests/python/proton_tests/codec.py          |  24 +-
 tests/python/proton_tests/engine.py         |  38 +-
 tests/python/proton_tests/interop.py        |   6 +-
 tests/python/proton_tests/message.py        |   6 +-
 tests/python/proton_tests/messenger.py      |   7 +-
 tests/python/proton_tests/sasl.py           |  14 +-
 tests/python/proton_tests/transport.py      |  20 +-
 tests/python/proton_tests/utils.py          |   3 +-
 tests/python/six.py                         | 849 -----------------------
 18 files changed, 198 insertions(+), 950 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
index 399aec7..864b25e 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -33,8 +33,8 @@ from __future__ import absolute_import
 
 from cproton import *
 from .wrapper import Wrapper
+from . import _compat
 
-import six
 import weakref, socket, sys, threading
 
 try:
@@ -805,7 +805,7 @@ class Message(object):
     self.annotations = None
     self.properties = None
     self.body = body
-    for k,v in six.iteritems(kwargs):
+    for k,v in _compat.iteritems(kwargs):
       getattr(self, k)          # Raise exception if it's not a valid attribute.
       setattr(self, k, v)
 
@@ -950,7 +950,7 @@ The number of delivery attempts made for this message.
   def _get_id(self):
     return self._id.get_object()
   def _set_id(self, value):
-    if type(value) in six.integer_types:
+    if type(value) in _compat.INT_TYPES:
       value = ulong(value)
     self._id.rewind()
     self._id.put_object(value)
@@ -1006,7 +1006,7 @@ The reply-to address for the message.
   def _get_correlation_id(self):
     return self._correlation_id.get_object()
   def _set_correlation_id(self, value):
-    if type(value) in six.integer_types:
+    if type(value) in _compat.INT_TYPES:
       value = ulong(value)
     self._correlation_id.rewind()
     self._correlation_id.put_object(value)
@@ -1438,7 +1438,7 @@ class Data:
   def type_name(type): return Data.type_names[type]
 
   def __init__(self, capacity=16):
-    if type(capacity) in six.integer_types:
+    if type(capacity) in _compat.INT_TYPES:
       self._data = pn_data(capacity)
       self._free = True
     else:
@@ -1941,7 +1941,7 @@ class Data:
     If the current node is a char, returns its value, returns 0
     otherwise.
     """
-    return char(six.unichr(pn_data_get_char(self._data)))
+    return char(_compat.unichar(pn_data_get_char(self._data)))
 
   def get_ulong(self):
     """
@@ -2340,12 +2340,12 @@ def unicode2utf8(string):
     """
     if string is None:
         return None
-    if six.PY2:
+    if _compat.IS_PY2:
         if isinstance(string, unicode):
             return string.encode('utf-8')
         elif isinstance(string, str):
             return string
-    elif six.PY3:
+    else:
         # decoding a string results in bytes
         if isinstance(string, str):
             string = string.encode('utf-8')
@@ -2358,10 +2358,10 @@ def utf82unicode(string):
     """Covert C strings returned from proton-c into python unicode"""
     if string is None:
         return None
-    if isinstance(string, six.text_type):
+    if isinstance(string, _compat.TEXT_TYPES):
         # already unicode
         return string
-    elif isinstance(string, six.binary_type):
+    elif isinstance(string, _compat.BINARY_TYPES):
         return string.decode('utf8')
     else:
         raise TypeError("Unrecognized string type")
@@ -2892,8 +2892,6 @@ class Sender(Link):
     @type data: binary
     @param data: data to send
     """
-    #if six.PY3 and isinstance(data, six.text_type):
-    #    data = data.encode('utf-8')
     return self._check(pn_link_send(self._impl, data))
 
   def send(self, obj, tag=None):
@@ -3767,7 +3765,7 @@ class _cadapter:
 
   def exception(self, exc, val, tb):
     if self.on_error is None:
-      six.reraise(exc, val, tb)
+      _compat.raise_(exc, val, tb)
     else:
       self.on_error((exc, val, tb))
 
@@ -3788,7 +3786,7 @@ class WrappedHandler(Wrapper):
   def _on_error(self, info):
     on_error = getattr(self, "on_error", None)
     if on_error is None:
-      six.reraise(info[0], info[1], info[2])
+      _compat.raise_(info[0], info[1], info[2])
     else:
       on_error(info)
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/proton-c/bindings/python/proton/_compat.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/_compat.py b/proton-c/bindings/python/proton/_compat.py
new file mode 100644
index 0000000..4585dfc
--- /dev/null
+++ b/proton-c/bindings/python/proton/_compat.py
@@ -0,0 +1,84 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+"""
+Utilities to help Proton support both python2 and python3.
+"""
+
+import sys
+import types
+IS_PY2 = sys.version_info[0] == 2
+IS_PY3 = sys.version_info[0] == 3
+
+if IS_PY3:
+    INT_TYPES = (int,)
+    TEXT_TYPES = (str,)
+    STRING_TYPES = (str,)
+    BINARY_TYPES = (bytes,)
+    CLASS_TYPES = (type,)
+
+    def raise_(t, v=None, tb=None):
+        """Mimic the old 2.x raise behavior:
+        Raise an exception of type t with value v using optional traceback tb
+        """
+        if v is None:
+            v = t()
+        if tb is None:
+            raise v
+        else:
+            raise v.with_traceback(tb)
+
+    def iteritems(d):
+        return iter(d.items())
+
+    def unichar(i):
+        return chr(i)
+
+    def str2bin(s, encoding='latin-1'):
+        """Convert str to binary type"""
+        return s.encode(encoding)
+
+    def str2unicode(s):
+        return s
+
+else:
+    INT_TYPES = (int, long)
+    TEXT_TYPES = (unicode,)
+    # includes both unicode and non-unicode strings:
+    STRING_TYPES = (basestring,)
+    BINARY_TYPES = (str,)
+    CLASS_TYPES = (type, types.ClassType)
+
+    # the raise syntax will cause a parse error in Py3, so 'sneak' in a
+    # definition that won't cause the parser to barf
+    exec("""def raise_(t, v=None, tb=None):
+    raise t, v, tb
+""")
+
+    def iteritems(d, **kw):
+        return d.iteritems()
+
+    def unichar(i):
+        return unichr(i)
+
+    def str2bin(s, encoding='latin-1'):
+        return s
+
+    def str2unicode(s):
+        return unicode(s, "unicode_escape")

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/proton-c/bindings/python/proton/handlers.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/handlers.py b/proton-c/bindings/python/proton/handlers.py
index 8f00aa3..9464302 100644
--- a/proton-c/bindings/python/proton/handlers.py
+++ b/proton-c/bindings/python/proton/handlers.py
@@ -17,7 +17,6 @@
 # under the License.
 #
 import heapq, logging, os, re, socket, time, types
-from six.moves import queue as Queue
 
 from proton import dispatch, generate_uuid, PN_ACCEPTED, SASL, symbol, ulong, Url
 from proton import Collector, Connection, Delivery, Described, Endpoint, Event, Link, Terminus, Timeout

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index b792c37..2260375 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -18,8 +18,6 @@ from __future__ import absolute_import
 # under the License.
 #
 import logging, os, socket, time, types
-import six
-from six.moves import queue as Queue
 from heapq import heappush, heappop, nsmallest
 from proton import Collector, Connection, ConnectionException, Delivery, Described, dispatch
 from proton import Endpoint, Event, EventBase, EventType, generate_uuid, Handler, Link, Message
@@ -33,6 +31,12 @@ import traceback
 from proton import WrappedHandler, _chandler, secs2millis, millis2secs, timeout2millis, millis2timeout, Selectable
 from .wrapper import Wrapper, PYCTX
 from cproton import *
+from . import _compat
+
+try:
+    import Queue
+except ImportError:
+    import queue as Queue
 
 class Task(Wrapper):
 
@@ -139,7 +143,7 @@ class Reactor(Wrapper):
             for exc, value, tb in self.errors[:-1]:
                 traceback.print_exception(exc, value, tb)
             exc, value, tb = self.errors[-1]
-            six.reraise(exc, value, tb)
+            _compat.raise_(exc, value, tb)
 
     def process(self):
         result = pn_reactor_process(self._impl)
@@ -211,7 +215,7 @@ class EventInjector(object):
         of the reactor to which this EventInjector was added.
         """
         self.queue.put(event)
-        os.write(self.pipe[1], six.b("!"))
+        os.write(self.pipe[1], _compat.str2bin("!"))
 
     def close(self):
         """
@@ -667,7 +671,7 @@ class Container(Reactor):
         Various LinkOptions can be specified to further control the
         attachment.
         """
-        if isinstance(context, six.string_types):
+        if isinstance(context, _compat.STRING_TYPES):
             context = Url(context)
         if isinstance(context, Url) and not target:
             target = context.path
@@ -708,7 +712,7 @@ class Container(Reactor):
         Various LinkOptions can be specified to further control the
         attachment.
         """
-        if isinstance(context, six.string_types):
+        if isinstance(context, _compat.STRING_TYPES):
             context = Url(context)
         if isinstance(context, Url) and not source:
             source = context.path

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/proton-c/bindings/python/proton/utils.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/utils.py b/proton-c/bindings/python/proton/utils.py
index 7b8ec13..880c466 100644
--- a/proton-c/bindings/python/proton/utils.py
+++ b/proton-c/bindings/python/proton/utils.py
@@ -17,8 +17,6 @@
 # under the License.
 #
 import collections, socket, time, threading
-import six
-from six.moves import queue as Queue
 
 from proton import ConnectionException, Delivery, Endpoint, Handler, LinkException, Message
 from proton import ProtonException, Timeout, Url

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/proton-c/mllib/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/__init__.py b/proton-c/mllib/__init__.py
index e506060..c0362cd 100644
--- a/proton-c/mllib/__init__.py
+++ b/proton-c/mllib/__init__.py
@@ -27,12 +27,17 @@ import os, sys
 import xml.sax, types
 from xml.sax.handler import ErrorHandler
 from xml.sax.xmlreader import InputSource
-import six
-from six.moves import cStringIO as StringIO
 
-from . import dom
-from . import transforms
-from . import parsers
+try:
+    from io import StringIO
+except ImportError:
+    from cStringIO import StringIO
+
+if sys.version_info[0] == 2:
+    import types
+    CLASS_TYPES = (type, types.ClassType)
+else:
+    CLASS_TYPES = (type,)
 
 from . import dom
 from . import transforms
@@ -41,7 +46,7 @@ from . import parsers
 def transform(node, *args):
   result = node
   for t in args:
-    if isinstance(t, six.class_types):
+    if isinstance(t, CLASS_TYPES):
       t = t()
     result = result.dispatch(t)
   return result

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/proton-c/mllib/dom.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/dom.py b/proton-c/mllib/dom.py
index b6ca27d..9421504 100644
--- a/proton-c/mllib/dom.py
+++ b/proton-c/mllib/dom.py
@@ -26,7 +26,11 @@ from __future__ import generators
 from __future__ import nested_scopes
 from __future__ import absolute_import
 
-import six
+import sys
+if sys.version_info[0] == 2:
+    STRING_TYPES = (basestring,)
+else:
+    STRING_TYPES = (str,)
 
 class Container:
 
@@ -179,7 +183,7 @@ class Leaf(Component, Dispatcher):
   base = None
 
   def __init__(self, data):
-    assert isinstance(data, six.string_types)
+    assert isinstance(data, STRING_TYPES)
     self.data = data
 
 class Data(Leaf):
@@ -269,7 +273,7 @@ class Values(View):
       yield value
 
 def flatten_path(path):
-  if isinstance(path, six.string_types):
+  if isinstance(path, STRING_TYPES):
     for part in path.split("/"):
       yield part
   elif callable(path):
@@ -292,7 +296,7 @@ class Query(View):
         select = Query
         pred = p
         source = query
-      elif isinstance(p, six.string_types):
+      elif isinstance(p, STRING_TYPES):
         if p[0] == "@":
           select = Values
           pred = lambda x, n=p[1:]: x[0] == n

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/proton-c/mllib/transforms.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/transforms.py b/proton-c/mllib/transforms.py
index 43e9ef2..910b507 100644
--- a/proton-c/mllib/transforms.py
+++ b/proton-c/mllib/transforms.py
@@ -23,7 +23,10 @@ Useful transforms for dom objects.
 from __future__ import absolute_import
 
 from . import dom
-from six.moves import cStringIO as StringIO
+try:
+    from io import StringIO
+except ImportError:
+    from cStringIO import StringIO
 
 class Visitor:
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/tests/python/proton-test
----------------------------------------------------------------------
diff --git a/tests/python/proton-test b/tests/python/proton-test
index 5073ab4..12ccb11 100755
--- a/tests/python/proton-test
+++ b/tests/python/proton-test
@@ -20,13 +20,17 @@
 
 # TODO: summarize, test harness preconditions (e.g. broker is alive)
 
-import six
 import logging, optparse, os, struct, sys, time, traceback, types, cgi
 from fnmatch import fnmatchcase as match
 from getopt import GetoptError
 from logging import getLogger, StreamHandler, Formatter, Filter, \
     WARN, DEBUG, ERROR
 
+if sys.version_info[0] == 3:
+    CLASS_TYPES = (type,)
+else:
+    CLASS_TYPES = (type, types.ClassType)
+
 levels = {
   "DEBUG": DEBUG,
   "WARN": WARN,
@@ -555,7 +559,7 @@ class FunctionScanner(PatternMatcher):
 class ClassScanner(PatternMatcher):
 
   def inspect(self, obj):
-    return type(obj) in six.class_types and self.matches(obj.__name__)
+    return type(obj) in CLASS_TYPES and self.matches(obj.__name__)
 
   def descend(self, cls):
     # the None is required for older versions of python
@@ -566,7 +570,7 @@ class ClassScanner(PatternMatcher):
     names.sort()
     for name in names:
       obj = getattr(cls, name)
-      if six.callable(obj) and name.startswith("test"):
+      if hasattr(obj, '__call__') and name.startswith("test"):
         yield MethodTest(cls, name)
 
 class ModuleScanner:
@@ -667,19 +671,19 @@ def runthrough():
       skip = "skip"
     else:
       skip = "pass"
-    six.print_(colorize("Totals:", 1), end=' ')
+    sys.stdout.write(colorize("Totals: ", 1))
     totals = [colorize_word("total", "%s tests" % total),
               colorize_word(_pass, "%s passed" % passed),
               colorize_word(skip, "%s skipped" % skipped),
               colorize_word(ign, "%s ignored" % len(ignored)),
               colorize_word(outcome, "%s failed" % failed)]
-    six.print_(", ".join(totals), end=' ')
+    sys.stdout.write(", ".join(totals))
     if opts.hoe and failed > 0:
       print(" -- (halted after %s)" % run)
     else:
-      print()
+      print("")
     if opts.time and run > 0:
-      six.print_(colorize("Timing:", 1), end=' ')
+      sys.stdout.write(colorize("Timing:", 1))
       timing = [colorize_word("elapsed", "%.2fs elapsed" % (end - start)),
                 colorize_word("average", "%.2fs average" % ((end - start)/run))]
       print(", ".join(timing))

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/tests/python/proton_tests/codec.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/codec.py b/tests/python/proton_tests/codec.py
index e340732..d924027 100644
--- a/tests/python/proton_tests/codec.py
+++ b/tests/python/proton_tests/codec.py
@@ -18,9 +18,9 @@
 #
 
 import os, sys
-import six
 from . import common
 from proton import *
+from proton._compat import raise_, str2unicode, unichar, str2bin
 try:
   from uuid import uuid4
 except ImportError:
@@ -129,7 +129,7 @@ class DataTest(Test):
       putter(v)
     except Exception:
       etype, value, trace = sys.exc_info()
-      six.reraise(etype, etype("%s(%r): %s" % (putter.__name__, v, value)), trace)
+      raise_(etype, etype("%s(%r): %s" % (putter.__name__, v, value)), trace)
     return putter
 
   # (bits, signed) for each integer type
@@ -275,8 +275,8 @@ class DataTest(Test):
     self._test("double", 0, 1, 2, 3, 0.1, 0.2, 0.3, -1, -2, -3, -0.1, -0.2, -0.3)
 
   def testBinary(self):
-    self._test("binary", six.b("this"), six.b("is"), six.b("a"), six.b("test"),
-               six.b("of" "b\x00inary"))
+    self._test("binary", str2bin("this"), str2bin("is"), str2bin("a"), str2bin("test"),
+               str2bin("of" "b\x00inary"))
 
   def testSymbol(self):
     self._test("symbol", "this is a symbol test", "bleh", "blah")
@@ -285,7 +285,7 @@ class DataTest(Test):
     self._test("timestamp", 0, 12345, 1000000)
 
   def testChar(self):
-    self._test("char", 'a', 'b', 'c', six.u('\u1234'))
+    self._test("char", 'a', 'b', 'c', unichar(0x20AC))
 
   def testUUID(self):
     self._test("uuid", uuid4(), uuid4(), uuid4())
@@ -297,7 +297,7 @@ class DataTest(Test):
     self._test("decimal64", 0, 1, 2, 3, 4, 2**60)
 
   def testDecimal128(self):
-    self._test("decimal128", six.b("fdsaasdf;lkjjkl;"), six.b("x"*16))
+    self._test("decimal128", str2bin("fdsaasdf;lkjjkl;"), str2bin("x"*16))
 
   def testCopy(self):
     self.data.put_described()
@@ -338,10 +338,10 @@ class DataTest(Test):
     obj = {symbol("key"): timestamp(1234),
            ulong(123): "blah",
            char("c"): "bleh",
-           six.u("desc"): Described(symbol("url"), six.u("http://example.org")),
-           six.u("array"): Array(UNDESCRIBED, Data.INT, 1, 2, 3),
-           six.u("list"): [1, 2, 3, None, 4],
-           six.u("boolean"): True}
+           str2unicode("desc"): Described(symbol("url"), str2unicode("http://example.org")),
+           str2unicode("array"): Array(UNDESCRIBED, Data.INT, 1, 2, 3),
+           str2unicode("list"): [1, 2, 3, None, 4],
+           str2unicode("boolean"): True}
     self.data.put_object(obj)
     enc = self.data.encode()
     data = Data()
@@ -352,7 +352,7 @@ class DataTest(Test):
     assert copy == obj, (copy, obj)
 
   def testLookup(self):
-    obj = {symbol("key"): six.u("value"),
+    obj = {symbol("key"): str2unicode("value"),
            symbol("pi"): 3.14159,
            symbol("list"): [1, 2, 3, 4]}
     self.data.put_object(obj)
@@ -364,7 +364,7 @@ class DataTest(Test):
     assert self.data.get_object() == 3.14159
     self.data.rewind()
     assert self.data.lookup("key")
-    assert self.data.get_object() == six.u("value")
+    assert self.data.get_object() == str2unicode("value")
     self.data.rewind()
     assert self.data.lookup("list")
     assert self.data.get_object() == [1, 2, 3, 4]

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index 55da0e5..0880682 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -1,4 +1,3 @@
-from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,14 +16,15 @@ from __future__ import absolute_import
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import absolute_import
 
 import os, gc
 from . import common
 from time import time, sleep
-import six
 from proton import *
 from .common import pump
 from proton.reactor import Reactor
+from proton._compat import str2bin
 
 # older versions of gc do not provide the garbage list
 if not hasattr(gc, "garbage"):
@@ -48,7 +48,7 @@ try:
     bytearray()
 except:
     def bytearray(x):
-        return six.b('\x00') * x
+        return str2bin('\x00') * x
 
 OUTPUT_SIZE = 10*1024
 
@@ -749,7 +749,7 @@ class TransferTest(Test):
     assert tag == "tag", tag
     assert d.writable
 
-    n = self.snd.send(six.b("this is a test"))
+    n = self.snd.send(str2bin("this is a test"))
     assert self.snd.advance()
     assert self.c1.work_head is None
 
@@ -762,7 +762,7 @@ class TransferTest(Test):
   def test_multiframe(self):
     self.rcv.flow(1)
     self.snd.delivery("tag")
-    msg = six.b("this is a test")
+    msg = str2bin("this is a test")
     n = self.snd.send(msg)
     assert n == len(msg)
 
@@ -777,9 +777,9 @@ class TransferTest(Test):
     assert binary == msg, (binary, msg)
 
     binary = self.rcv.recv(1024)
-    assert binary == six.b("")
+    assert binary == str2bin("")
 
-    msg = six.b("this is more")
+    msg = str2bin("this is more")
     n = self.snd.send(msg)
     assert n == len(msg)
     assert self.snd.advance()
@@ -798,7 +798,7 @@ class TransferTest(Test):
     self.pump()
 
     sd = self.snd.delivery("tag")
-    msg = six.b("this is a test")
+    msg = str2bin("this is a test")
     n = self.snd.send(msg)
     assert n == len(msg)
     assert self.snd.advance()
@@ -897,7 +897,7 @@ class TransferTest(Test):
 
     for x in range(10):
         self.snd.delivery("tag%d" % x)
-        msg = six.b("this is a test")
+        msg = str2bin("this is a test")
         n = self.snd.send(msg)
         assert n == len(msg)
         assert self.snd.advance()
@@ -1413,7 +1413,7 @@ class CreditTest(Test):
 
     sd = self.snd.delivery("tagA")
     assert sd
-    n = self.snd.send(six.b("A"))
+    n = self.snd.send(str2bin("A"))
     assert n == 1
     self.pump()
     self.snd.advance()
@@ -1430,7 +1430,7 @@ class CreditTest(Test):
     assert self.rcv.credit == 10, self.rcv.credit
 
     data = self.rcv.recv(10)
-    assert data == six.b("A"), data
+    assert data == str2bin("A"), data
     self.rcv.advance()
     self.pump()
     assert self.snd.credit == 9, self.snd.credit
@@ -1451,7 +1451,7 @@ class CreditTest(Test):
 
     sd = self.snd.delivery("tagB")
     assert sd
-    n = self.snd.send(six.b("B"))
+    n = self.snd.send(str2bin("B"))
     assert n == 1
     self.snd.advance()
     self.pump()
@@ -1465,7 +1465,7 @@ class CreditTest(Test):
 
     sd = self.snd.delivery("tagC")
     assert sd
-    n = self.snd.send(six.b("C"))
+    n = self.snd.send(str2bin("C"))
     assert n == 1
     self.snd.advance()
     self.pump()
@@ -1480,10 +1480,10 @@ class CreditTest(Test):
     assert self.rcv.credit == 2, self.rcv.credit
 
     data = self.rcv.recv(10)
-    assert data == six.b("B"), data
+    assert data == str2bin("B"), data
     self.rcv.advance()
     data = self.rcv.recv(10)
-    assert data == six.b("C"), data
+    assert data == str2bin("C"), data
     self.rcv.advance()
     self.pump()
     assert self.snd.credit == 0, self.snd.credit
@@ -1818,7 +1818,7 @@ class PipelineTest(Test):
 
     for i in range(10):
       d = snd.delivery("delivery-%s" % i)
-      snd.send(six.b("delivery-%s" % i))
+      snd.send(str2bin("delivery-%s" % i))
       d.settle()
 
     snd.close()
@@ -2250,7 +2250,7 @@ class EventTest(CollectorTest):
     self.expect(Event.CONNECTION_INIT, Event.SESSION_INIT,
                 Event.LINK_INIT, Event.LINK_LOCAL_OPEN, Event.TRANSPORT)
     snd.delivery("delivery")
-    snd.send(six.b("Hello World!"))
+    snd.send(str2bin("Hello World!"))
     snd.advance()
     self.pump()
     self.expect()
@@ -2266,7 +2266,7 @@ class EventTest(CollectorTest):
     snd, rcv = self.testFlowEvents()
     snd.open()
     dlv = snd.delivery("delivery")
-    snd.send(six.b("Hello World!"))
+    snd.send(str2bin("Hello World!"))
     assert snd.advance()
     self.expect(Event.LINK_LOCAL_OPEN, Event.TRANSPORT)
     self.pump()
@@ -2297,7 +2297,7 @@ class EventTest(CollectorTest):
     t.bind(c)
     self.expect(Event.CONNECTION_BOUND)
     assert t.condition is None
-    t.push(six.b("asdf"))
+    t.push(str2bin("asdf"))
     self.expect(Event.TRANSPORT_ERROR, Event.TRANSPORT_TAIL_CLOSED)
     assert t.condition is not None
     assert t.condition.name == "amqp:connection:framing-error"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/tests/python/proton_tests/interop.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/interop.py b/tests/python/proton_tests/interop.py
index 5cbab99..4eedf3c 100644
--- a/tests/python/proton_tests/interop.py
+++ b/tests/python/proton_tests/interop.py
@@ -19,8 +19,8 @@
 
 from proton import *
 import os
-import six
 from . import common
+from proton._compat import str2bin
 
 
 def find_test_interop_dir():
@@ -100,10 +100,10 @@ class InteropTest(common.Test):
 
     def test_strings(self):
         self.decode_data_file("strings")
-        self.assert_next(Data.BINARY, six.b("abc\0defg"))
+        self.assert_next(Data.BINARY, str2bin("abc\0defg"))
         self.assert_next(Data.STRING, "abcdefg")
         self.assert_next(Data.SYMBOL, "abcdefg")
-        self.assert_next(Data.BINARY, six.b(""))
+        self.assert_next(Data.BINARY, str2bin(""))
         self.assert_next(Data.STRING, "")
         self.assert_next(Data.SYMBOL, "")
         assert self.data.next() is None

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/tests/python/proton_tests/message.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/message.py b/tests/python/proton_tests/message.py
index 10d2326..2f7cb4f 100644
--- a/tests/python/proton_tests/message.py
+++ b/tests/python/proton_tests/message.py
@@ -18,9 +18,9 @@
 #
 
 import os
-import six
 from . import common
 from proton import *
+from proton._compat import str2bin
 try:
   from uuid import uuid4
 except ImportError:
@@ -73,8 +73,8 @@ class AccessorsTest(Test):
     self._test("delivery_count", 0, range(0, 1024))
 
   def testUserId(self):
-    self._test("user_id", six.b(""), (six.b("asdf"), six.b("fdsa"),
-                                      six.b("asd\x00fdsa"), six.b("")))
+    self._test("user_id", str2bin(""), (str2bin("asdf"), str2bin("fdsa"),
+                                      str2bin("asd\x00fdsa"), str2bin("")))
 
   def testAddress(self):
     self._test_str("address")

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/tests/python/proton_tests/messenger.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/messenger.py b/tests/python/proton_tests/messenger.py
index 30d0ec5..e139b3c 100644
--- a/tests/python/proton_tests/messenger.py
+++ b/tests/python/proton_tests/messenger.py
@@ -19,7 +19,6 @@ from __future__ import absolute_import
 #
 
 import os, sys, traceback
-from six.moves import range as xrange
 from . import common
 from proton import *
 from threading import Thread, Event
@@ -762,8 +761,8 @@ class NBMessengerTest(common.Test):
 
     msg = Message()
     msg.address = self.address
-    for i in xrange(16):
-      for i in xrange(1024):
+    for i in range(16):
+      for i in range(1024):
         self.client.put(msg)
       self.pump()
       if self.client.outgoing > 0:
@@ -801,7 +800,7 @@ class NBMessengerTest(common.Test):
     deadline = time() + self.timeout
     while time() < deadline:
         old = self.server.incoming
-        for j in xrange(1001):
+        for j in range(1001):
             self.client.put(msg)
         self.pump()
         if old == self.server.incoming:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index 2734364..ce10882 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -1,4 +1,3 @@
-from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,12 +16,13 @@ from __future__ import absolute_import
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import absolute_import
 
 import sys, os
-import six
 from . import common
 from proton import *
 from .common import pump, Skipped
+from proton._compat import str2bin
 
 class Test(common.Test):
   pass
@@ -122,7 +122,7 @@ class SaslTest(Test):
     c1.open()
 
     # get all t1's output in one buffer then pass it all to t2
-    out1_sasl_and_amqp = six.b("")
+    out1_sasl_and_amqp = str2bin("")
     t1_still_producing = True
     while t1_still_producing:
       out1 = self.t1.peek(1024)
@@ -172,17 +172,17 @@ class SaslTest(Test):
 
     out = self.t1.peek(1024)
     self.t1.pop(len(out))
-    self.t1.push(six.b("AMQP\x03\x01\x00\x00"))
+    self.t1.push(str2bin("AMQP\x03\x01\x00\x00"))
     out = self.t1.peek(1024)
     self.t1.pop(len(out))
-    self.t1.push(six.b("\x00\x00\x00"))
+    self.t1.push(str2bin("\x00\x00\x00"))
     out = self.t1.peek(1024)
     self.t1.pop(len(out))
 
-    self.t1.push(six.b("6\x02\x01\x00\x00\x00S@\xc04\x01\xe01\x04\xa3\x05PLAIN\x0aDIGEST-MD5\x09ANONYMOUS\x08CRAM-MD5"))
+    self.t1.push(str2bin("6\x02\x01\x00\x00\x00S@\xc04\x01\xe01\x04\xa3\x05PLAIN\x0aDIGEST-MD5\x09ANONYMOUS\x08CRAM-MD5"))
     out = self.t1.peek(1024)
     self.t1.pop(len(out))
-    self.t1.push(six.b("\x00\x00\x00\x10\x02\x01\x00\x00\x00SD\xc0\x03\x01P\x00"))
+    self.t1.push(str2bin("\x00\x00\x00\x10\x02\x01\x00\x00\x00SD\xc0\x03\x01P\x00"))
     out = self.t1.peek(1024)
     self.t1.pop(len(out))
     while out:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/tests/python/proton_tests/transport.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/transport.py b/tests/python/proton_tests/transport.py
index 0b22f4e..243b3cb 100644
--- a/tests/python/proton_tests/transport.py
+++ b/tests/python/proton_tests/transport.py
@@ -18,9 +18,9 @@
 #
 
 import os
-import six
 from . import common
 from proton import *
+from proton._compat import str2bin
 
 
 class Test(common.Test):
@@ -62,16 +62,16 @@ class TransportTest(Test):
     assert self.conn.remote_condition.name == name, self.conn.remote_condition
 
   def testEOS(self):
-    self.transport.push(six.b("")) # should be a noop
+    self.transport.push(str2bin("")) # should be a noop
     self.transport.close_tail() # should result in framing error
     self.assert_error(u'amqp:connection:framing-error')
 
   def testPartial(self):
-    self.transport.push(six.b("AMQ")) # partial header
+    self.transport.push(str2bin("AMQ")) # partial header
     self.transport.close_tail() # should result in framing error
     self.assert_error(u'amqp:connection:framing-error')
 
-  def testGarbage(self, garbage=six.b("GARBAGE_")):
+  def testGarbage(self, garbage=str2bin("GARBAGE_")):
     self.transport.push(garbage)
     self.assert_error(u'amqp:connection:framing-error')
     assert self.transport.pending() < 0
@@ -79,13 +79,13 @@ class TransportTest(Test):
     assert self.transport.pending() < 0
 
   def testSmallGarbage(self):
-    self.testGarbage(six.b("XXX"))
+    self.testGarbage(str2bin("XXX"))
 
   def testBigGarbage(self):
-    self.testGarbage(six.b("GARBAGE_XXX"))
+    self.testGarbage(str2bin("GARBAGE_XXX"))
 
   def testHeader(self):
-    self.transport.push(six.b("AMQP\x00\x01\x00\x00"))
+    self.transport.push(str2bin("AMQP\x00\x01\x00\x00"))
     self.transport.close_tail()
     self.assert_error(u'amqp:connection:framing-error')
 
@@ -103,8 +103,8 @@ class TransportTest(Test):
     trn = Transport()
     trn.bind(conn)
     out = trn.peek(1024)
-    assert six.b("test-container") in out, repr(out)
-    assert six.b("test-hostname") in out, repr(out)
+    assert str2bin("test-container") in out, repr(out)
+    assert str2bin("test-hostname") in out, repr(out)
     self.transport.push(out)
 
     c = Connection()
@@ -161,7 +161,7 @@ class TransportTest(Test):
     self.transport.pop(len(dat2) - len(dat1))
     dat3 = self.transport.peek(1024)
     self.transport.pop(len(dat3))
-    assert self.transport.peek(1024) == six.b("")
+    assert self.transport.peek(1024) == str2bin("")
 
     self.peer.push(dat1)
     self.peer.push(dat2[len(dat1):])

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/tests/python/proton_tests/utils.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/utils.py b/tests/python/proton_tests/utils.py
index 86eb6f3..1ddccc4 100644
--- a/tests/python/proton_tests/utils.py
+++ b/tests/python/proton_tests/utils.py
@@ -18,7 +18,6 @@
 #
 
 import os, time
-from six.moves import range as xrange
 from threading import Thread, Event
 from unittest import TestCase
 from proton_tests.common import Test, free_tcp_port
@@ -78,7 +77,7 @@ class SyncRequestResponseTest(Test):
 
     def test_request_response(self):
         def test(name, address="x"):
-            for i in xrange(5):
+            for i in range(5):
                 body="%s%s" % (name, i)
                 response = client.call(Message(address=address, body=body))
                 self.assertEquals(response.address, client.reply_to)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/646ee41c/tests/python/six.py
----------------------------------------------------------------------
diff --git a/tests/python/six.py b/tests/python/six.py
deleted file mode 100644
index 4b572bb..0000000
--- a/tests/python/six.py
+++ /dev/null
@@ -1,849 +0,0 @@
-"""Utilities for writing code that runs on Python 2 and 3"""
-
-# Copyright (c) 2010-2015 Benjamin Peterson
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-
-from __future__ import absolute_import
-
-import functools
-import itertools
-import operator
-import sys
-import types
-
-__author__ = "Benjamin Peterson <be...@python.org>"
-__version__ = "1.9.0"
-
-
-# begin QPID
-# added to support running the unit tests under JYTHON
-if not hasattr(operator, 'methodcaller'):
-    def _methodcaller(cls, name, *args, **kwargs):
-        def caller(obj):
-            return getattr(obj, name)(*args, **kwargs)
-        return caller
-    operator.methodcaller = classmethod(_methodcaller)
-# QPID end
-
-
-# Useful for very coarse version differentiation.
-PY2 = sys.version_info[0] == 2
-PY3 = sys.version_info[0] == 3
-
-if PY3:
-    string_types = str,
-    integer_types = int,
-    class_types = type,
-    text_type = str
-    binary_type = bytes
-
-    MAXSIZE = sys.maxsize
-else:
-    string_types = basestring,
-    integer_types = (int, long)
-    class_types = (type, types.ClassType)
-    text_type = unicode
-    binary_type = str
-
-    if sys.platform.startswith("java"):
-        # Jython always uses 32 bits.
-        MAXSIZE = int((1 << 31) - 1)
-    else:
-        # It's possible to have sizeof(long) != sizeof(Py_ssize_t).
-        class X(object):
-            def __len__(self):
-                return 1 << 31
-        try:
-            len(X())
-        except OverflowError:
-            # 32-bit
-            MAXSIZE = int((1 << 31) - 1)
-        else:
-            # 64-bit
-            MAXSIZE = int((1 << 63) - 1)
-        del X
-
-
-def _add_doc(func, doc):
-    """Add documentation to a function."""
-    func.__doc__ = doc
-
-
-def _import_module(name):
-    """Import module, returning the module after the last dot."""
-    __import__(name)
-    return sys.modules[name]
-
-
-class _LazyDescr(object):
-
-    def __init__(self, name):
-        self.name = name
-
-    def __get__(self, obj, tp):
-        result = self._resolve()
-        setattr(obj, self.name, result) # Invokes __set__.
-        try:
-            # This is a bit ugly, but it avoids running this again by
-            # removing this descriptor.
-            delattr(obj.__class__, self.name)
-        except AttributeError:
-            pass
-        return result
-
-
-class MovedModule(_LazyDescr):
-
-    def __init__(self, name, old, new=None):
-        super(MovedModule, self).__init__(name)
-        if PY3:
-            if new is None:
-                new = name
-            self.mod = new
-        else:
-            self.mod = old
-
-    def _resolve(self):
-        return _import_module(self.mod)
-
-    def __getattr__(self, attr):
-        _module = self._resolve()
-        value = getattr(_module, attr)
-        setattr(self, attr, value)
-        return value
-
-
-class _LazyModule(types.ModuleType):
-
-    def __init__(self, name):
-        super(_LazyModule, self).__init__(name)
-        self.__doc__ = self.__class__.__doc__
-
-    def __dir__(self):
-        attrs = ["__doc__", "__name__"]
-        attrs += [attr.name for attr in self._moved_attributes]
-        return attrs
-
-    # Subclasses should override this
-    _moved_attributes = []
-
-
-class MovedAttribute(_LazyDescr):
-
-    def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
-        super(MovedAttribute, self).__init__(name)
-        if PY3:
-            if new_mod is None:
-                new_mod = name
-            self.mod = new_mod
-            if new_attr is None:
-                if old_attr is None:
-                    new_attr = name
-                else:
-                    new_attr = old_attr
-            self.attr = new_attr
-        else:
-            self.mod = old_mod
-            if old_attr is None:
-                old_attr = name
-            self.attr = old_attr
-
-    def _resolve(self):
-        module = _import_module(self.mod)
-        return getattr(module, self.attr)
-
-
-class _SixMetaPathImporter(object):
-    """
-    A meta path importer to import six.moves and its submodules.
-
-    This class implements a PEP302 finder and loader. It should be compatible
-    with Python 2.5 and all existing versions of Python3
-    """
-    def __init__(self, six_module_name):
-        self.name = six_module_name
-        self.known_modules = {}
-
-    def _add_module(self, mod, *fullnames):
-        for fullname in fullnames:
-            self.known_modules[self.name + "." + fullname] = mod
-
-    def _get_module(self, fullname):
-        return self.known_modules[self.name + "." + fullname]
-
-    def find_module(self, fullname, path=None):
-        if fullname in self.known_modules:
-            return self
-        return None
-
-    def __get_module(self, fullname):
-        try:
-            return self.known_modules[fullname]
-        except KeyError:
-            raise ImportError("This loader does not know module " + fullname)
-
-    def load_module(self, fullname):
-        try:
-            # in case of a reload
-            return sys.modules[fullname]
-        except KeyError:
-            pass
-        mod = self.__get_module(fullname)
-        if isinstance(mod, MovedModule):
-            mod = mod._resolve()
-        else:
-            mod.__loader__ = self
-        sys.modules[fullname] = mod
-        return mod
-
-    def is_package(self, fullname):
-        """
-        Return true, if the named module is a package.
-
-        We need this method to get correct spec objects with
-        Python 3.4 (see PEP451)
-        """
-        return hasattr(self.__get_module(fullname), "__path__")
-
-    def get_code(self, fullname):
-        """Return None
-
-        Required, if is_package is implemented"""
-        self.__get_module(fullname)  # eventually raises ImportError
-        return None
-    get_source = get_code  # same as get_code
-
-_importer = _SixMetaPathImporter(__name__)
-
-
-class _MovedItems(_LazyModule):
-    """Lazy loading of moved objects"""
-    __path__ = []  # mark as package
-
-
-_moved_attributes = [
-    MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
-    MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
-    MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"),
-    MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
-    MovedAttribute("intern", "__builtin__", "sys"),
-    MovedAttribute("map", "itertools", "builtins", "imap", "map"),
-    MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
-    MovedAttribute("reload_module", "__builtin__", "imp", "reload"),
-    MovedAttribute("reduce", "__builtin__", "functools"),
-    MovedAttribute("shlex_quote", "pipes", "shlex", "quote"),
-    MovedAttribute("StringIO", "StringIO", "io"),
-    MovedAttribute("UserDict", "UserDict", "collections"),
-    MovedAttribute("UserList", "UserList", "collections"),
-    MovedAttribute("UserString", "UserString", "collections"),
-    MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
-    MovedAttribute("zip", "itertools", "builtins", "izip", "zip"),
-    MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
-
-    MovedModule("builtins", "__builtin__"),
-    MovedModule("configparser", "ConfigParser"),
-    MovedModule("copyreg", "copy_reg"),
-    MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
-    MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"),
-    MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
-    MovedModule("http_cookies", "Cookie", "http.cookies"),
-    MovedModule("html_entities", "htmlentitydefs", "html.entities"),
-    MovedModule("html_parser", "HTMLParser", "html.parser"),
-    MovedModule("http_client", "httplib", "http.client"),
-    MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"),
-    MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"),
-    MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"),
-    MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
-    MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
-    MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"),
-    MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"),
-    MovedModule("cPickle", "cPickle", "pickle"),
-    MovedModule("queue", "Queue"),
-    MovedModule("reprlib", "repr"),
-    MovedModule("socketserver", "SocketServer"),
-    MovedModule("_thread", "thread", "_thread"),
-    MovedModule("tkinter", "Tkinter"),
-    MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"),
-    MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"),
-    MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"),
-    MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"),
-    MovedModule("tkinter_tix", "Tix", "tkinter.tix"),
-    MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"),
-    MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"),
-    MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"),
-    MovedModule("tkinter_colorchooser", "tkColorChooser",
-                "tkinter.colorchooser"),
-    MovedModule("tkinter_commondialog", "tkCommonDialog",
-                "tkinter.commondialog"),
-    MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"),
-    MovedModule("tkinter_font", "tkFont", "tkinter.font"),
-    MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"),
-    MovedModule("tkinter_tksimpledialog", "tkSimpleDialog",
-                "tkinter.simpledialog"),
-    MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"),
-    MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"),
-    MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"),
-    MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"),
-    MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"),
-    MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"),
-    MovedModule("winreg", "_winreg"),
-]
-for attr in _moved_attributes:
-    setattr(_MovedItems, attr.name, attr)
-    if isinstance(attr, MovedModule):
-        _importer._add_module(attr, "moves." + attr.name)
-del attr
-
-_MovedItems._moved_attributes = _moved_attributes
-
-moves = _MovedItems(__name__ + ".moves")
-_importer._add_module(moves, "moves")
-
-
-class Module_six_moves_urllib_parse(_LazyModule):
-    """Lazy loading of moved objects in six.moves.urllib_parse"""
-
-
-_urllib_parse_moved_attributes = [
-    MovedAttribute("ParseResult", "urlparse", "urllib.parse"),
-    MovedAttribute("SplitResult", "urlparse", "urllib.parse"),
-    MovedAttribute("parse_qs", "urlparse", "urllib.parse"),
-    MovedAttribute("parse_qsl", "urlparse", "urllib.parse"),
-    MovedAttribute("urldefrag", "urlparse", "urllib.parse"),
-    MovedAttribute("urljoin", "urlparse", "urllib.parse"),
-    MovedAttribute("urlparse", "urlparse", "urllib.parse"),
-    MovedAttribute("urlsplit", "urlparse", "urllib.parse"),
-    MovedAttribute("urlunparse", "urlparse", "urllib.parse"),
-    MovedAttribute("urlunsplit", "urlparse", "urllib.parse"),
-    MovedAttribute("quote", "urllib", "urllib.parse"),
-    MovedAttribute("quote_plus", "urllib", "urllib.parse"),
-    MovedAttribute("unquote", "urllib", "urllib.parse"),
-    MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
-    MovedAttribute("urlencode", "urllib", "urllib.parse"),
-    MovedAttribute("splitquery", "urllib", "urllib.parse"),
-    MovedAttribute("splittag", "urllib", "urllib.parse"),
-    MovedAttribute("splituser", "urllib", "urllib.parse"),
-    MovedAttribute("uses_fragment", "urlparse", "urllib.parse"),
-    MovedAttribute("uses_netloc", "urlparse", "urllib.parse"),
-    MovedAttribute("uses_params", "urlparse", "urllib.parse"),
-    MovedAttribute("uses_query", "urlparse", "urllib.parse"),
-    MovedAttribute("uses_relative", "urlparse", "urllib.parse"),
-]
-for attr in _urllib_parse_moved_attributes:
-    setattr(Module_six_moves_urllib_parse, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"),
-                      "moves.urllib_parse", "moves.urllib.parse")
-
-
-class Module_six_moves_urllib_error(_LazyModule):
-    """Lazy loading of moved objects in six.moves.urllib_error"""
-
-
-_urllib_error_moved_attributes = [
-    MovedAttribute("URLError", "urllib2", "urllib.error"),
-    MovedAttribute("HTTPError", "urllib2", "urllib.error"),
-    MovedAttribute("ContentTooShortError", "urllib", "urllib.error"),
-]
-for attr in _urllib_error_moved_attributes:
-    setattr(Module_six_moves_urllib_error, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"),
-                      "moves.urllib_error", "moves.urllib.error")
-
-
-class Module_six_moves_urllib_request(_LazyModule):
-    """Lazy loading of moved objects in six.moves.urllib_request"""
-
-
-_urllib_request_moved_attributes = [
-    MovedAttribute("urlopen", "urllib2", "urllib.request"),
-    MovedAttribute("install_opener", "urllib2", "urllib.request"),
-    MovedAttribute("build_opener", "urllib2", "urllib.request"),
-    MovedAttribute("pathname2url", "urllib", "urllib.request"),
-    MovedAttribute("url2pathname", "urllib", "urllib.request"),
-    MovedAttribute("getproxies", "urllib", "urllib.request"),
-    MovedAttribute("Request", "urllib2", "urllib.request"),
-    MovedAttribute("OpenerDirector", "urllib2", "urllib.request"),
-    MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"),
-    MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"),
-    MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"),
-    MovedAttribute("ProxyHandler", "urllib2", "urllib.request"),
-    MovedAttribute("BaseHandler", "urllib2", "urllib.request"),
-    MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"),
-    MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"),
-    MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"),
-    MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"),
-    MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"),
-    MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"),
-    MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"),
-    MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"),
-    MovedAttribute("HTTPHandler", "urllib2", "urllib.request"),
-    MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"),
-    MovedAttribute("FileHandler", "urllib2", "urllib.request"),
-    MovedAttribute("FTPHandler", "urllib2", "urllib.request"),
-    MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"),
-    MovedAttribute("UnknownHandler", "urllib2", "urllib.request"),
-    MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"),
-    MovedAttribute("urlretrieve", "urllib", "urllib.request"),
-    MovedAttribute("urlcleanup", "urllib", "urllib.request"),
-    MovedAttribute("URLopener", "urllib", "urllib.request"),
-    MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
-    MovedAttribute("proxy_bypass", "urllib", "urllib.request"),
-]
-for attr in _urllib_request_moved_attributes:
-    setattr(Module_six_moves_urllib_request, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"),
-                      "moves.urllib_request", "moves.urllib.request")
-
-
-class Module_six_moves_urllib_response(_LazyModule):
-    """Lazy loading of moved objects in six.moves.urllib_response"""
-
-
-_urllib_response_moved_attributes = [
-    MovedAttribute("addbase", "urllib", "urllib.response"),
-    MovedAttribute("addclosehook", "urllib", "urllib.response"),
-    MovedAttribute("addinfo", "urllib", "urllib.response"),
-    MovedAttribute("addinfourl", "urllib", "urllib.response"),
-]
-for attr in _urllib_response_moved_attributes:
-    setattr(Module_six_moves_urllib_response, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"),
-                      "moves.urllib_response", "moves.urllib.response")
-
-
-class Module_six_moves_urllib_robotparser(_LazyModule):
-    """Lazy loading of moved objects in six.moves.urllib_robotparser"""
-
-
-_urllib_robotparser_moved_attributes = [
-    MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"),
-]
-for attr in _urllib_robotparser_moved_attributes:
-    setattr(Module_six_moves_urllib_robotparser, attr.name, attr)
-del attr
-
-Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes
-
-_importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"),
-                      "moves.urllib_robotparser", "moves.urllib.robotparser")
-
-
-class Module_six_moves_urllib(types.ModuleType):
-    """Create a six.moves.urllib namespace that resembles the Python 3 namespace"""
-    __path__ = []  # mark as package
-    parse = _importer._get_module("moves.urllib_parse")
-    error = _importer._get_module("moves.urllib_error")
-    request = _importer._get_module("moves.urllib_request")
-    response = _importer._get_module("moves.urllib_response")
-    robotparser = _importer._get_module("moves.urllib_robotparser")
-
-    def __dir__(self):
-        return ['parse', 'error', 'request', 'response', 'robotparser']
-
-_importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"),
-                      "moves.urllib")
-
-
-def add_move(move):
-    """Add an item to six.moves."""
-    setattr(_MovedItems, move.name, move)
-
-
-def remove_move(name):
-    """Remove item from six.moves."""
-    try:
-        delattr(_MovedItems, name)
-    except AttributeError:
-        try:
-            del moves.__dict__[name]
-        except KeyError:
-            raise AttributeError("no such move, %r" % (name,))
-
-
-if PY3:
-    _meth_func = "__func__"
-    _meth_self = "__self__"
-
-    _func_closure = "__closure__"
-    _func_code = "__code__"
-    _func_defaults = "__defaults__"
-    _func_globals = "__globals__"
-else:
-    _meth_func = "im_func"
-    _meth_self = "im_self"
-
-    _func_closure = "func_closure"
-    _func_code = "func_code"
-    _func_defaults = "func_defaults"
-    _func_globals = "func_globals"
-
-
-try:
-    advance_iterator = next
-except NameError:
-    def advance_iterator(it):
-        return it.next()
-next = advance_iterator
-
-
-try:
-    callable = callable
-except NameError:
-    def callable(obj):
-        return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)
-
-
-if PY3:
-    def get_unbound_function(unbound):
-        return unbound
-
-    create_bound_method = types.MethodType
-
-    Iterator = object
-else:
-    def get_unbound_function(unbound):
-        return unbound.im_func
-
-    def create_bound_method(func, obj):
-        return types.MethodType(func, obj, obj.__class__)
-
-    class Iterator(object):
-
-        def next(self):
-            return type(self).__next__(self)
-
-    callable = callable
-_add_doc(get_unbound_function,
-         """Get the function out of a possibly unbound function""")
-
-
-get_method_function = operator.attrgetter(_meth_func)
-get_method_self = operator.attrgetter(_meth_self)
-get_function_closure = operator.attrgetter(_func_closure)
-get_function_code = operator.attrgetter(_func_code)
-get_function_defaults = operator.attrgetter(_func_defaults)
-get_function_globals = operator.attrgetter(_func_globals)
-
-
-if PY3:
-    def iterkeys(d, **kw):
-        return iter(d.keys(**kw))
-
-    def itervalues(d, **kw):
-        return iter(d.values(**kw))
-
-    def iteritems(d, **kw):
-        return iter(d.items(**kw))
-
-    def iterlists(d, **kw):
-        return iter(d.lists(**kw))
-
-    viewkeys = operator.methodcaller("keys")
-
-    viewvalues = operator.methodcaller("values")
-
-    viewitems = operator.methodcaller("items")
-else:
-    def iterkeys(d, **kw):
-        return iter(d.iterkeys(**kw))
-
-    def itervalues(d, **kw):
-        return iter(d.itervalues(**kw))
-
-    def iteritems(d, **kw):
-        return iter(d.iteritems(**kw))
-
-    def iterlists(d, **kw):
-        return iter(d.iterlists(**kw))
-
-    viewkeys = operator.methodcaller("viewkeys")
-
-    viewvalues = operator.methodcaller("viewvalues")
-
-    viewitems = operator.methodcaller("viewitems")
-
-_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.")
-_add_doc(itervalues, "Return an iterator over the values of a dictionary.")
-_add_doc(iteritems,
-         "Return an iterator over the (key, value) pairs of a dictionary.")
-_add_doc(iterlists,
-         "Return an iterator over the (key, [values]) pairs of a dictionary.")
-
-
-if PY3:
-    def b(s):
-        return s.encode("latin-1")
-    def u(s):
-        return s
-    unichr = chr
-    if sys.version_info[1] <= 1:
-        def int2byte(i):
-            return bytes((i,))
-    else:
-        # This is about 2x faster than the implementation above on 3.2+
-        int2byte = operator.methodcaller("to_bytes", 1, "big")
-    byte2int = operator.itemgetter(0)
-    indexbytes = operator.getitem
-    iterbytes = iter
-    import io
-    StringIO = io.StringIO
-    BytesIO = io.BytesIO
-    _assertCountEqual = "assertCountEqual"
-    _assertRaisesRegex = "assertRaisesRegex"
-    _assertRegex = "assertRegex"
-else:
-    def b(s):
-        return s
-    # Workaround for standalone backslash
-    def u(s):
-        return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
-    unichr = unichr
-    int2byte = chr
-    def byte2int(bs):
-        return ord(bs[0])
-    def indexbytes(buf, i):
-        return ord(buf[i])
-    iterbytes = functools.partial(itertools.imap, ord)
-    import StringIO
-    StringIO = BytesIO = StringIO.StringIO
-    _assertCountEqual = "assertItemsEqual"
-    _assertRaisesRegex = "assertRaisesRegexp"
-    _assertRegex = "assertRegexpMatches"
-_add_doc(b, """Byte literal""")
-_add_doc(u, """Text literal""")
-
-
-def assertCountEqual(self, *args, **kwargs):
-    return getattr(self, _assertCountEqual)(*args, **kwargs)
-
-
-def assertRaisesRegex(self, *args, **kwargs):
-    return getattr(self, _assertRaisesRegex)(*args, **kwargs)
-
-
-def assertRegex(self, *args, **kwargs):
-    return getattr(self, _assertRegex)(*args, **kwargs)
-
-
-if PY3:
-    exec_ = getattr(moves.builtins, "exec")
-
-
-    def reraise(tp, value, tb=None):
-        if value is None:
-            value = tp()
-        if value.__traceback__ is not tb:
-            raise value.with_traceback(tb)
-        raise value
-
-else:
-    def exec_(_code_, _globs_=None, _locs_=None):
-        """Execute code in a namespace."""
-        if _globs_ is None:
-            frame = sys._getframe(1)
-            _globs_ = frame.f_globals
-            if _locs_ is None:
-                _locs_ = frame.f_locals
-            del frame
-        elif _locs_ is None:
-            _locs_ = _globs_
-        exec("""exec _code_ in _globs_, _locs_""")
-
-
-    exec_("""def reraise(tp, value, tb=None):
-    raise tp, value, tb
-""")
-
-
-if sys.version_info[:2] == (3, 2):
-    exec_("""def raise_from(value, from_value):
-    if from_value is None:
-        raise value
-    raise value from from_value
-""")
-elif sys.version_info[:2] > (3, 2):
-    exec_("""def raise_from(value, from_value):
-    raise value from from_value
-""")
-else:
-    def raise_from(value, from_value):
-        raise value
-
-
-print_ = getattr(moves.builtins, "print", None)
-if print_ is None:
-    def print_(*args, **kwargs):
-        """The new-style print function for Python 2.4 and 2.5."""
-        fp = kwargs.pop("file", sys.stdout)
-        if fp is None:
-            return
-        def write(data):
-            if not isinstance(data, basestring):
-                data = str(data)
-            # If the file has an encoding, encode unicode with it.
-            if (isinstance(fp, file) and
-                isinstance(data, unicode) and
-                fp.encoding is not None):
-                errors = getattr(fp, "errors", None)
-                if errors is None:
-                    errors = "strict"
-                data = data.encode(fp.encoding, errors)
-            fp.write(data)
-        want_unicode = False
-        sep = kwargs.pop("sep", None)
-        if sep is not None:
-            if isinstance(sep, unicode):
-                want_unicode = True
-            elif not isinstance(sep, str):
-                raise TypeError("sep must be None or a string")
-        end = kwargs.pop("end", None)
-        if end is not None:
-            if isinstance(end, unicode):
-                want_unicode = True
-            elif not isinstance(end, str):
-                raise TypeError("end must be None or a string")
-        if kwargs:
-            raise TypeError("invalid keyword arguments to print()")
-        if not want_unicode:
-            for arg in args:
-                if isinstance(arg, unicode):
-                    want_unicode = True
-                    break
-        if want_unicode:
-            newline = unicode("\n")
-            space = unicode(" ")
-        else:
-            newline = "\n"
-            space = " "
-        if sep is None:
-            sep = space
-        if end is None:
-            end = newline
-        for i, arg in enumerate(args):
-            if i:
-                write(sep)
-            write(arg)
-        write(end)
-if sys.version_info[:2] < (3, 3):
-    _print = print_
-    def print_(*args, **kwargs):
-        fp = kwargs.get("file", sys.stdout)
-        flush = kwargs.pop("flush", False)
-        _print(*args, **kwargs)
-        if flush and fp is not None:
-            fp.flush()
-
-_add_doc(reraise, """Reraise an exception.""")
-
-if sys.version_info[0:2] < (3, 4):
-    def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
-              updated=functools.WRAPPER_UPDATES):
-        def wrapper(f):
-            f = functools.wraps(wrapped, assigned, updated)(f)
-            f.__wrapped__ = wrapped
-            return f
-        return wrapper
-else:
-    wraps = functools.wraps
-
-def with_metaclass(meta, *bases):
-    """Create a base class with a metaclass."""
-    # This requires a bit of explanation: the basic idea is to make a dummy
-    # metaclass for one level of class instantiation that replaces itself with
-    # the actual metaclass.
-    class metaclass(meta):
-        def __new__(cls, name, this_bases, d):
-            return meta(name, bases, d)
-    return type.__new__(metaclass, 'temporary_class', (), {})
-
-
-def add_metaclass(metaclass):
-    """Class decorator for creating a class with a metaclass."""
-    def wrapper(cls):
-        orig_vars = cls.__dict__.copy()
-        slots = orig_vars.get('__slots__')
-        if slots is not None:
-            if isinstance(slots, str):
-                slots = [slots]
-            for slots_var in slots:
-                orig_vars.pop(slots_var)
-        orig_vars.pop('__dict__', None)
-        orig_vars.pop('__weakref__', None)
-        return metaclass(cls.__name__, cls.__bases__, orig_vars)
-    return wrapper
-
-
-def python_2_unicode_compatible(klass):
-    """
-    A decorator that defines __unicode__ and __str__ methods under Python 2.
-    Under Python 3 it does nothing.
-
-    To support Python 2 and 3 with a single code base, define a __str__ method
-    returning text and apply this decorator to the class.
-    """
-    if PY2:
-        if '__str__' not in klass.__dict__:
-            raise ValueError("@python_2_unicode_compatible cannot be applied "
-                             "to %s because it doesn't define __str__()." %
-                             klass.__name__)
-        klass.__unicode__ = klass.__str__
-        klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
-    return klass
-
-
-# Complete the moves implementation.
-# This code is at the end of this module to speed up module loading.
-# Turn this module into a package.
-__path__ = []  # required for PEP 302 and PEP 451
-__package__ = __name__  # see PEP 366 @ReservedAssignment
-if globals().get("__spec__") is not None:
-    __spec__.submodule_search_locations = []  # PEP 451 @UndefinedVariable
-# Remove other six meta path importers, since they cause problems. This can
-# happen if six is removed from sys.modules and then reloaded. (Setuptools does
-# this for some reason.)
-if sys.meta_path:
-    for i, importer in enumerate(sys.meta_path):
-        # Here's some real nastiness: Another "instance" of the six module might
-        # be floating around. Therefore, we can't use isinstance() to check for
-        # the six meta path importer, since the other six instance will have
-        # inserted an importer with different class.
-        if (type(importer).__name__ == "_SixMetaPathImporter" and
-            importer.name == __name__):
-            del sys.meta_path[i]
-            break
-    del i, importer
-# Finally, add the importer to the meta path import hook.
-sys.meta_path.append(_importer)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[29/34] qpid-proton git commit: PROTON-490: Merge all sections into testenv

Posted by kg...@apache.org.
PROTON-490: Merge all sections into testenv

(cherry picked from commit 33f486b59975d7bb10c48ad419ad7f1d5cf20e6f)


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

Branch: refs/heads/master
Commit: 13cc7292b947d64abc5512a5d0afa6e7cf072350
Parents: 6069e1f
Author: Flavio Percoco <fl...@gmail.com>
Authored: Thu Jun 18 09:58:40 2015 +0200
Committer: Ken Giusti <kg...@apache.org>
Committed: Thu Jun 18 14:00:28 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/tox.ini | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/13cc7292/proton-c/bindings/python/tox.ini
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/tox.ini b/proton-c/bindings/python/tox.ini
index 6bbe1fc..8a8c87c 100644
--- a/proton-c/bindings/python/tox.ini
+++ b/proton-c/bindings/python/tox.ini
@@ -6,6 +6,7 @@ skipdist = True
 [testenv]
 usedevelop = False
 #changedir = {toxinidir}/../../proton-c/include/
+platform = linux|linux2
 setenv =
     VIRTUAL_ENV={envdir}
     PKG_CONFIG_PATH=None
@@ -22,12 +23,3 @@ commands = flake8
 
 [testenv:docs]
 commands = python setup.py build_sphinx
-
-[testenv:py27]
-platform = linux|linux2
-
-[testenv:py33]
-platform = linux|linux2
-
-[testenv:py34]
-platform = linux|linux2


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[03/34] qpid-proton git commit: PROTON-490: futurize the python code under the test directory

Posted by kg...@apache.org.
PROTON-490: futurize the python code under the test directory


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

Branch: refs/heads/master
Commit: 979471f5ee355b3eca43f8cf176ebc7e241ab603
Parents: aae1d20
Author: Ken Giusti <kg...@apache.org>
Authored: Fri Apr 17 09:39:51 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Apr 20 12:46:47 2015 -0400

----------------------------------------------------------------------
 tests/python/proton_tests/codec.py     | 87 +++++++++++++++--------------
 tests/python/proton_tests/common.py    | 24 +++++++-
 tests/python/proton_tests/engine.py    |  8 ++-
 tests/python/proton_tests/interop.py   | 21 +++----
 tests/python/proton_tests/message.py   |  3 +-
 tests/python/proton_tests/messenger.py |  9 ++-
 tests/python/proton_tests/reactor.py   |  3 +-
 tests/python/proton_tests/sasl.py      |  6 +-
 tests/python/proton_tests/soak.py      |  3 +-
 tests/python/proton_tests/ssl.py       | 11 ++--
 tests/python/proton_tests/transport.py |  9 ++-
 tests/python/proton_tests/url.py       |  3 +-
 tests/smoke/recv.py                    |  3 +-
 tests/smoke/send.py                    |  5 +-
 tests/tools/apps/python/msgr-recv.py   |  1 +
 tests/tools/apps/python/msgr-send.py   |  1 +
 16 files changed, 121 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/codec.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/codec.py b/tests/python/proton_tests/codec.py
index 81bb4de..e8893cf 100644
--- a/tests/python/proton_tests/codec.py
+++ b/tests/python/proton_tests/codec.py
@@ -17,7 +17,8 @@
 # under the License.
 #
 
-import os, common, sys
+import os, sys
+from . import common
 from proton import *
 try:
   from uuid import uuid4
@@ -36,58 +37,58 @@ class Test(common.Test):
 class DataTest(Test):
 
   def testTopLevelNext(self):
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_null()
     self.data.put_bool(False)
     self.data.put_int(0)
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.rewind()
-    assert self.data.next() == Data.NULL
-    assert self.data.next() == Data.BOOL
-    assert self.data.next() == Data.INT
-    assert self.data.next() is None
+    assert next(self.data) == Data.NULL
+    assert next(self.data) == Data.BOOL
+    assert next(self.data) == Data.INT
+    assert next(self.data) is None
 
   def testNestedNext(self):
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_null()
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_list()
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_bool(False)
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.rewind()
-    assert self.data.next() is Data.NULL
-    assert self.data.next() is Data.LIST
+    assert next(self.data) is Data.NULL
+    assert next(self.data) is Data.LIST
     self.data.enter()
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_ubyte(0)
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_uint(0)
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_int(0)
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.exit()
-    assert self.data.next() is Data.BOOL
-    assert self.data.next() is None
+    assert next(self.data) is Data.BOOL
+    assert next(self.data) is None
 
     self.data.rewind()
-    assert self.data.next() is Data.NULL
-    assert self.data.next() is Data.LIST
+    assert next(self.data) is Data.NULL
+    assert next(self.data) is Data.LIST
     assert self.data.enter()
-    assert self.data.next() is Data.UBYTE
-    assert self.data.next() is Data.UINT
-    assert self.data.next() is Data.INT
-    assert self.data.next() is None
+    assert next(self.data) is Data.UBYTE
+    assert next(self.data) is Data.UINT
+    assert next(self.data) is Data.INT
+    assert next(self.data) is None
     assert self.data.exit()
-    assert self.data.next() is Data.BOOL
-    assert self.data.next() is None
+    assert next(self.data) is Data.BOOL
+    assert next(self.data) is None
 
   def testEnterExit(self):
-    assert self.data.next() is None
+    assert next(self.data) is None
     assert not self.data.enter()
     self.data.put_list()
     assert self.data.enter()
-    assert self.data.next() is None
+    assert next(self.data) is None
     self.data.put_list()
     assert self.data.enter()
     self.data.put_list()
@@ -100,19 +101,19 @@ class DataTest(Test):
     assert self.data.get_list() == 1
     assert not self.data.exit()
     assert self.data.get_list() == 1
-    assert self.data.next() is None
+    assert next(self.data) is None
 
     self.data.rewind()
-    assert self.data.next() is Data.LIST
+    assert next(self.data) is Data.LIST
     assert self.data.get_list() == 1
     assert self.data.enter()
-    assert self.data.next() is Data.LIST
+    assert next(self.data) is Data.LIST
     assert self.data.get_list() == 1
     assert self.data.enter()
-    assert self.data.next() is Data.LIST
+    assert next(self.data) is Data.LIST
     assert self.data.get_list() == 0
     assert self.data.enter()
-    assert self.data.next() is None
+    assert next(self.data) is None
     assert self.data.exit()
     assert self.data.get_list() == 0
     assert self.data.exit()
@@ -126,7 +127,7 @@ class DataTest(Test):
     """More informative exception from putters, include bad value"""
     try:
       putter(v)
-    except Exception, e:
+    except Exception:
       etype, value, trace = sys.exc_info()
       raise etype, "%s(%r): %s" % (putter.__name__, v, value), trace
     return putter
@@ -168,7 +169,7 @@ class DataTest(Test):
       self.put(putter, v)
     self.data.exit()
     self.data.rewind()
-    assert self.data.next() == Data.ARRAY
+    assert next(self.data) == Data.ARRAY
     count, described, type = self.data.get_array()
     assert count == len(values), count
     if dtype is None:
@@ -178,17 +179,17 @@ class DataTest(Test):
     assert type == aTYPE, type
     assert self.data.enter()
     if described:
-      assert self.data.next() == dTYPE
+      assert next(self.data) == dTYPE
       getter = getattr(self.data, "get_%s" % dtype)
       gotten = getter()
       assert gotten == descriptor, gotten
     if values:
       getter = getattr(self.data, "get_%s" % atype)
       for v in values:
-        assert self.data.next() == aTYPE
+        assert next(self.data) == aTYPE
         gotten = getter()
         assert gotten == v, gotten
-    assert self.data.next() is None
+    assert next(self.data) is None
     assert self.data.exit()
 
   def testStringArray(self):
@@ -230,7 +231,7 @@ class DataTest(Test):
     self.data.rewind()
 
     for v in values:
-      vtype = self.data.next()
+      vtype = next(self.data)
       assert vtype == ntype, vtype
       gotten = getter()
       assert eq(gotten, v), (gotten, v)
@@ -245,7 +246,7 @@ class DataTest(Test):
     cgetter = getattr(copy, "get_%s" % dtype)
 
     for v in values:
-      vtype = copy.next()
+      vtype = next(copy)
       assert vtype == ntype, vtype
       gotten = cgetter()
       assert eq(gotten, v), (gotten, v)
@@ -345,7 +346,7 @@ class DataTest(Test):
     data = Data()
     data.decode(enc)
     data.rewind()
-    assert data.next()
+    assert next(data)
     copy = data.get_object()
     assert copy == obj, (copy, obj)
 
@@ -355,7 +356,7 @@ class DataTest(Test):
            symbol("list"): [1, 2, 3, 4]}
     self.data.put_object(obj)
     self.data.rewind()
-    self.data.next()
+    next(self.data)
     self.data.enter()
     self.data.narrow()
     assert self.data.lookup("pi")

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py b/tests/python/proton_tests/common.py
index 1b8dbdb..585ea02 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -27,6 +27,27 @@ from proton import Connection, Transport, SASL, Endpoint, Delivery, SSL
 from proton.reactor import Container
 from proton.handlers import CHandshaker, CFlowController
 
+if sys.version_info[0] == 2 and sys.version_info[1] < 6:
+    # this is for compatibility, apparently the version of jython we
+    # use doesn't have the next() builtin.
+    # we should remove this when we upgrade to a python 2.6+ compatible version
+    # of jython
+    #_DEF = object()  This causes the test loader to fail (why?)
+    class _dummy(): pass
+    _DEF = _dummy
+
+    def next(iter, default=_DEF):
+        try:
+            return iter.next()
+        except StopIteration:
+            if default is _DEF:
+                raise
+            else:
+                return default
+    # I may goto hell for this:
+    import __builtin__
+    __builtin__.__dict__['next'] = next
+
 
 def free_tcp_ports(count=1):
   """ return a list of 'count' TCP ports that are free to used (ie. unbound)
@@ -224,7 +245,8 @@ class MessengerApp(object):
                     cmd.insert(0, foundfile)
                     cmd.insert(0, sys.executable)
             self._process = Popen(cmd, stdout=PIPE, stderr=STDOUT, bufsize=4096)
-        except OSError, e:
+        except OSError:
+            e = sys.exc_info()[1]
             print("ERROR: '%s'" % e)
             assert False, "Unable to execute command '%s', is it in your PATH?" % cmd[0]
         self._ready()  # wait for it to initialize

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index 99125d9..7835792 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,10 +18,11 @@
 # under the License.
 #
 
-import os, common, gc
+import os, gc
+from . import common
 from time import time, sleep
 from proton import *
-from common import pump
+from .common import pump
 from proton.reactor import Reactor
 
 # older versions of gc do not provide the garbage list
@@ -1836,7 +1838,7 @@ class PipelineTest(Test):
     assert rcv.queued == 0, rcv.queued
 
 import sys
-from common import Skipped
+from .common import Skipped
 
 class ServerTest(Test):
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/interop.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/interop.py b/tests/python/proton_tests/interop.py
index baf998d..1ef92dd 100644
--- a/tests/python/proton_tests/interop.py
+++ b/tests/python/proton_tests/interop.py
@@ -18,7 +18,8 @@
 #
 
 from proton import *
-import os, common
+import os
+from . import common
 
 
 def find_test_interop_dir():
@@ -70,7 +71,7 @@ class InteropTest(common.Test):
         self.decode_data(body)
 
     def assert_next(self, type, value):
-        next_type = self.data.next()
+        next_type = next(self.data)
         assert next_type == type, "Type mismatch: %s != %s"%(
             Data.type_names[next_type], Data.type_names[type])
         next_value = self.data.get_object()
@@ -79,7 +80,7 @@ class InteropTest(common.Test):
     def test_message(self):
         self.decode_message_file("message")
         self.assert_next(Data.STRING, "hello")
-        assert self.data.next() is None
+        assert next(self.data) is None
 
     def test_primitives(self):
         self.decode_data_file("primitives")
@@ -94,7 +95,7 @@ class InteropTest(common.Test):
         self.assert_next(Data.LONG, -12345)
         self.assert_next(Data.FLOAT, 0.125)
         self.assert_next(Data.DOUBLE, 0.125)
-        assert self.data.next() is None
+        assert next(self.data) is None
 
     def test_strings(self):
         self.decode_data_file("strings")
@@ -104,20 +105,20 @@ class InteropTest(common.Test):
         self.assert_next(Data.BINARY, "")
         self.assert_next(Data.STRING, "")
         self.assert_next(Data.SYMBOL, "")
-        assert self.data.next() is None
+        assert next(self.data) is None
 
     def test_described(self):
         self.decode_data_file("described")
         self.assert_next(Data.DESCRIBED, Described("foo-descriptor", "foo-value"))
         self.data.exit()
 
-        assert self.data.next() == Data.DESCRIBED
+        assert next(self.data) == Data.DESCRIBED
         self.data.enter()
         self.assert_next(Data.INT, 12)
         self.assert_next(Data.INT, 13)
         self.data.exit()
 
-        assert self.data.next() is None
+        assert next(self.data) is None
 
     def test_described_array(self):
         self.decode_data_file("described_array")
@@ -128,17 +129,17 @@ class InteropTest(common.Test):
         self.assert_next(Data.ARRAY, Array(UNDESCRIBED, Data.INT, *range(0,100)))
         self.assert_next(Data.ARRAY, Array(UNDESCRIBED, Data.STRING, *["a", "b", "c"]))
         self.assert_next(Data.ARRAY, Array(UNDESCRIBED, Data.INT))
-        assert self.data.next() is None
+        assert next(self.data) is None
 
     def test_lists(self):
         self.decode_data_file("lists")
         self.assert_next(Data.LIST, [32, "foo", True])
         self.assert_next(Data.LIST, [])
-        assert self.data.next() is None
+        assert next(self.data) is None
 
     def test_maps(self):
         self.decode_data_file("maps")
         self.assert_next(Data.MAP, {"one":1, "two":2, "three":3 })
         self.assert_next(Data.MAP, {1:"one", 2:"two", 3:"three"})
         self.assert_next(Data.MAP, {})
-        assert self.data.next() is None
+        assert next(self.data) is None

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/message.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/message.py b/tests/python/proton_tests/message.py
index 6bf94fe..3366366 100644
--- a/tests/python/proton_tests/message.py
+++ b/tests/python/proton_tests/message.py
@@ -17,7 +17,8 @@
 # under the License.
 #
 
-import os, common
+import os
+from . import common
 from proton import *
 try:
   from uuid import uuid4

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/messenger.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/messenger.py b/tests/python/proton_tests/messenger.py
index c7c7dd3..03a1b6b 100644
--- a/tests/python/proton_tests/messenger.py
+++ b/tests/python/proton_tests/messenger.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,11 +18,12 @@
 # under the License.
 #
 
-import os, common, sys, traceback
+import os, sys, traceback
+from . import common
 from proton import *
 from threading import Thread, Event
 from time import sleep, time
-from common import Skipped
+from .common import Skipped
 
 class Test(common.Test):
 
@@ -180,7 +182,8 @@ class MessengerTest(Test):
     try:
       self.client.put(msg)
       assert False, "Expecting MessengerException"
-    except MessengerException, exc:
+    except MessengerException:
+      exc = sys.exc_info()[1]
       err = str(exc)
       assert "unable to send to address: totally-bogus-address" in err, err
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index 4e660a5..6afee30 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,7 +18,7 @@
 # under the License.
 #
 
-from common import Test
+from .common import Test
 from proton.reactor import Reactor
 
 class Barf(Exception):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index a14a0db..0d6761f 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,9 +18,10 @@
 # under the License.
 #
 
-import os, common
+import os
+from . import common
 from proton import *
-from common import pump
+from .common import pump
 
 class Test(common.Test):
   pass

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/soak.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/soak.py b/tests/python/proton_tests/soak.py
index 9e5ceab..0a6e693 100644
--- a/tests/python/proton_tests/soak.py
+++ b/tests/python/proton_tests/soak.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +19,7 @@
 #
 import os
 import sys
-from common import Test, Skipped, free_tcp_ports, \
+from .common import Test, Skipped, free_tcp_ports, \
     MessengerReceiverC, MessengerSenderC, \
     MessengerReceiverValgrind, MessengerSenderValgrind, \
     MessengerReceiverPython, MessengerSenderPython, \

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/ssl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/ssl.py b/tests/python/proton_tests/ssl.py
index f5fae3f..fd5aaf1 100644
--- a/tests/python/proton_tests/ssl.py
+++ b/tests/python/proton_tests/ssl.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,13 +18,14 @@
 # under the License.
 #
 
-import os, common
+import os
+from . import common
 import random
 import string
 import subprocess
 
 from proton import *
-from common import Skipped, pump
+from .common import Skipped, pump
 
 
 def _testpath(file):
@@ -791,7 +793,7 @@ class SslTest(common.Test):
         try:
             ssl3 = SSL(transport, self.server_domain)
             assert False, "Expected error did not occur!"
-        except SSLException, e:
+        except SSLException:
             pass
 
 class MessengerSSLTests(common.Test):
@@ -834,7 +836,8 @@ class MessengerSSLTests(common.Test):
             self.server.subscribe("amqps://~0.0.0.0:12345")
             if exception is not None:
                 assert False, "expected failure did not occur"
-        except MessengerException, e:
+        except MessengerException:
+            e = sys.exc_info()[1]
             if exception:
                 assert exception in str(e), str(e)
             else:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/transport.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/transport.py b/tests/python/proton_tests/transport.py
index dcf7636..512d816 100644
--- a/tests/python/proton_tests/transport.py
+++ b/tests/python/proton_tests/transport.py
@@ -17,7 +17,8 @@
 # under the License.
 #
 
-import os, common
+import os
+from . import common
 from proton import *
 
 
@@ -119,7 +120,8 @@ class TransportTest(Test):
     assert n > 0, n
     try:
       self.transport.close_head()
-    except TransportException, e:
+    except TransportException:
+      e = sys.exc_info()[1]
       assert "aborted" in str(e), str(e)
     n = self.transport.pending()
     assert n < 0, n
@@ -129,7 +131,8 @@ class TransportTest(Test):
     assert n > 0, n
     try:
       self.transport.close_tail()
-    except TransportException, e:
+    except TransportException:
+      e = sys.exc_info()[1]
       assert "aborted" in str(e), str(e)
     n = self.transport.capacity()
     assert n < 0, n

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/url.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/url.py b/tests/python/proton_tests/url.py
index 77a16ff..40a257c 100644
--- a/tests/python/proton_tests/url.py
+++ b/tests/python/proton_tests/url.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +19,7 @@
 #
 
 
-import common
+from . import common
 from proton import Url
 
 class UrlTest(common.Test):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/smoke/recv.py
----------------------------------------------------------------------
diff --git a/tests/smoke/recv.py b/tests/smoke/recv.py
index 3b2b0e5..e6aa2b6 100755
--- a/tests/smoke/recv.py
+++ b/tests/smoke/recv.py
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+from __future__ import print_function
 import sys
 from proton import *
 
@@ -16,7 +17,7 @@ messenger.start()
 while True:
   messenger.recv()
   messenger.get(message)
-  print "Got: %s" % message
+  print("Got: %s" % message)
   messenger.accept()
 
 messenger.stop()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/smoke/send.py
----------------------------------------------------------------------
diff --git a/tests/smoke/send.py b/tests/smoke/send.py
index 1aed9c8..7daee01 100755
--- a/tests/smoke/send.py
+++ b/tests/smoke/send.py
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+from __future__ import print_function
 import sys
 from proton import *
 
@@ -17,7 +18,7 @@ message.body = u"Hello World!"
 
 messenger.start()
 tracker = messenger.put(message)
-print "Put: %s" % message
+print("Put: %s" % message)
 messenger.send()
-print "Status: %s" % messenger.status(tracker)
+print("Status: %s" % messenger.status(tracker))
 messenger.stop()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/tools/apps/python/msgr-recv.py
----------------------------------------------------------------------
diff --git a/tests/tools/apps/python/msgr-recv.py b/tests/tools/apps/python/msgr-recv.py
index 73c2a3a..079c871 100755
--- a/tests/tools/apps/python/msgr-recv.py
+++ b/tests/tools/apps/python/msgr-recv.py
@@ -18,6 +18,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse, time
 import logging
 from proton import *

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/tools/apps/python/msgr-send.py
----------------------------------------------------------------------
diff --git a/tests/tools/apps/python/msgr-send.py b/tests/tools/apps/python/msgr-send.py
index 872122b..a2f67c5 100755
--- a/tests/tools/apps/python/msgr-send.py
+++ b/tests/tools/apps/python/msgr-send.py
@@ -18,6 +18,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse, time
 import logging
 from proton import *


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[23/34] qpid-proton git commit: PROTON-490: Make setup py34 compatible

Posted by kg...@apache.org.
PROTON-490: Make setup py34 compatible


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

Branch: refs/heads/master
Commit: fc3f4f5b1592e6b57f5e64a691a96d91c6742d5f
Parents: 2721c63
Author: Flavio Percoco <fl...@gmail.com>
Authored: Sun Jun 14 00:08:02 2015 +0200
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Jun 15 13:28:30 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/setup.py |  7 +++++--
 proton-c/bindings/python/tox.ini  | 19 ++++++++++++-------
 2 files changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fc3f4f5b/proton-c/bindings/python/setup.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setup.py b/proton-c/bindings/python/setup.py
index 84b5a66..e6fbb79 100755
--- a/proton-c/bindings/python/setup.py
+++ b/proton-c/bindings/python/setup.py
@@ -149,7 +149,7 @@ class Configure(build_ext):
 #define PN_VERSION_MINOR %i
 #endif /* version.h */
 """ % bundle.min_qpid_proton
-            ver.write(version_text)
+            ver.write(version_text.encode('utf-8'))
 
         # Collect all the C files that need to be built.
         # we could've used `glob(.., '*', '*.c')` but I preferred going
@@ -269,6 +269,9 @@ class Configure(build_ext):
 
         _cproton.runtime_library_dirs.extend([install_lib])
 
+        if sys.version_info.major >= 3:
+            _cproton.libraries[0] = "qpid-proton%s" % ds_sys.get_config_var('EXT_SUFFIX')[:-3]
+
         # Register this new extension and make
         # sure it's built and installed *before* `_cproton`.
         self.distribution.ext_modules.insert(0, libqpid_proton)
@@ -283,7 +286,7 @@ class Configure(build_ext):
     @property
     def bundle_proton(self):
         """Bundled proton if the conditions below are met."""
-        return sys.platform == 'linux2' and not self.check_qpid_proton_version()
+        return 'linux' in sys.platform and not self.check_qpid_proton_version()
 
     def run(self):
         if self.bundle_proton:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fc3f4f5b/proton-c/bindings/python/tox.ini
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/tox.ini b/proton-c/bindings/python/tox.ini
index dddfe74..b2277da 100644
--- a/proton-c/bindings/python/tox.ini
+++ b/proton-c/bindings/python/tox.ini
@@ -1,9 +1,10 @@
 [tox]
-envlist = build
+envlist = build,py34
 minversion = 1.4
 skipdist = True
 
 [testenv]
+usedevelop = False
 changedir = {toxinidir}/../../proton-c/include/
 setenv =
     VIRTUAL_ENV={envdir}
@@ -11,8 +12,7 @@ passenv =
     PKG_CONFIG_PATH
     CFLAGS
 commands =
-    pip install -e {toxinidir}
-    tests/python/proton-test {posargs}
+    {toxinidir}/../../../tests/python/proton-test {posargs}
 
 [testenv:pep8]
 commands = flake8
@@ -20,13 +20,18 @@ commands = flake8
 [testenv:docs]
 commands = python setup.py build_sphinx
 
+[testenv:py34]
+platform = linux
+setenv =
+    VIRTUAL_ENV={envdir}
+    PKG_CONFIG_PATH=None
+    QPID_PROTON_SRC={toxinidir}/../../../
+    DEBUG=True
+
 [testenv:build]
-usedevelop = False
 platform = linux2
 setenv =
     VIRTUAL_ENV={envdir}
     PKG_CONFIG_PATH=None
     QPID_PROTON_SRC={toxinidir}/../../../
-    DEBUG=True
-commands =
-    {toxinidir}/../../../tests/python/proton-test {posargs}
\ No newline at end of file
+    DEBUG=True
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[14/34] qpid-proton git commit: PROTON-490: covert python examples using 2to3

Posted by kg...@apache.org.
PROTON-490: covert python examples using 2to3


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

Branch: refs/heads/master
Commit: d31100aae5b8e539111fc65a13f1bc8b782c787e
Parents: 64cb4fa
Author: Ken Giusti <kg...@apache.org>
Authored: Mon Apr 27 17:04:10 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Apr 27 17:25:32 2015 -0400

----------------------------------------------------------------------
 examples/python/db_common.py                 | 6 +++++-
 examples/python/db_send.py                   | 7 ++++++-
 examples/python/helloworld.py                | 2 +-
 examples/python/helloworld_blocking.py       | 2 +-
 examples/python/helloworld_direct.py         | 2 +-
 examples/python/helloworld_direct_tornado.py | 2 +-
 examples/python/helloworld_tornado.py        | 2 +-
 examples/python/messenger/async.py           | 2 +-
 examples/python/messenger/send.py            | 2 +-
 examples/python/selected_recv.py             | 2 +-
 proton-c/bindings/python/proton/reactor.py   | 2 +-
 11 files changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d31100aa/examples/python/db_common.py
----------------------------------------------------------------------
diff --git a/examples/python/db_common.py b/examples/python/db_common.py
index 85f8191..54af87b 100755
--- a/examples/python/db_common.py
+++ b/examples/python/db_common.py
@@ -18,7 +18,11 @@
 # under the License.
 #
 
-import Queue
+try:
+    import Queue
+except:
+    import queue as Queue
+
 import sqlite3
 import threading
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d31100aa/examples/python/db_send.py
----------------------------------------------------------------------
diff --git a/examples/python/db_send.py b/examples/python/db_send.py
index 99558d5..dc85df9 100755
--- a/examples/python/db_send.py
+++ b/examples/python/db_send.py
@@ -20,8 +20,13 @@
 
 from __future__ import print_function
 import optparse
-import Queue
 import time
+try:
+    import Queue
+except:
+    import queue as Queue
+
+
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton.reactor import ApplicationEvent, Container, EventInjector

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d31100aa/examples/python/helloworld.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld.py b/examples/python/helloworld.py
index d73a4cb..9fcd6f1 100755
--- a/examples/python/helloworld.py
+++ b/examples/python/helloworld.py
@@ -35,7 +35,7 @@ class HelloWorld(MessagingHandler):
         event.container.create_sender(conn, self.address)
 
     def on_sendable(self, event):
-        event.sender.send(Message(body=u"Hello World!"))
+        event.sender.send(Message(body="Hello World!"))
         event.sender.close()
 
     def on_message(self, event):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d31100aa/examples/python/helloworld_blocking.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_blocking.py b/examples/python/helloworld_blocking.py
index 049f148..5a5ce6d 100755
--- a/examples/python/helloworld_blocking.py
+++ b/examples/python/helloworld_blocking.py
@@ -26,7 +26,7 @@ from proton.handlers import IncomingMessageHandler
 conn = BlockingConnection("localhost:5672")
 receiver = conn.create_receiver("examples")
 sender = conn.create_sender("examples")
-sender.send(Message(body=u"Hello World!"));
+sender.send(Message(body="Hello World!"));
 msg = receiver.receive(timeout=30)
 print(msg.body)
 receiver.accept()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d31100aa/examples/python/helloworld_direct.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_direct.py b/examples/python/helloworld_direct.py
index d6374a2..264e5b8 100755
--- a/examples/python/helloworld_direct.py
+++ b/examples/python/helloworld_direct.py
@@ -33,7 +33,7 @@ class HelloWorld(MessagingHandler):
         event.container.create_sender(self.url)
 
     def on_sendable(self, event):
-        event.sender.send(Message(body=u"Hello World!"))
+        event.sender.send(Message(body="Hello World!"))
         event.sender.close()
 
     def on_message(self, event):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d31100aa/examples/python/helloworld_direct_tornado.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_direct_tornado.py b/examples/python/helloworld_direct_tornado.py
index 9ef2ed7..a3b017a 100755
--- a/examples/python/helloworld_direct_tornado.py
+++ b/examples/python/helloworld_direct_tornado.py
@@ -33,7 +33,7 @@ class HelloWorld(MessagingHandler):
         event.container.create_sender(self.url)
 
     def on_sendable(self, event):
-        event.sender.send(Message(body=u"Hello World!"))
+        event.sender.send(Message(body="Hello World!"))
         event.sender.close()
 
     def on_message(self, event):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d31100aa/examples/python/helloworld_tornado.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_tornado.py b/examples/python/helloworld_tornado.py
index 3cb2ad1..0781bbb 100755
--- a/examples/python/helloworld_tornado.py
+++ b/examples/python/helloworld_tornado.py
@@ -35,7 +35,7 @@ class HelloWorld(MessagingHandler):
         event.container.create_sender(conn, self.address)
 
     def on_sendable(self, event):
-        event.sender.send(Message(body=u"Hello World!"))
+        event.sender.send(Message(body="Hello World!"))
         event.sender.close()
 
     def on_message(self, event):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d31100aa/examples/python/messenger/async.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/async.py b/examples/python/messenger/async.py
index b3f5c45..a1b0292 100755
--- a/examples/python/messenger/async.py
+++ b/examples/python/messenger/async.py
@@ -58,7 +58,7 @@ class CallbackAdapter:
         self._process_incoming()
 
     def _process_outgoing(self):
-        for t, on_status in self.tracked.items():
+        for t, on_status in list(self.tracked.items()):
             status = self.messenger.status(t)
             if status != PENDING:
                 on_status(status)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d31100aa/examples/python/messenger/send.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/send.py b/examples/python/messenger/send.py
index f40e7b1..c274656 100755
--- a/examples/python/messenger/send.py
+++ b/examples/python/messenger/send.py
@@ -36,7 +36,7 @@ mng.start()
 msg = Message()
 for m in args:
   msg.address = opts.address
-  msg.body = unicode(m)
+  msg.body = str(m)
   mng.put(msg)
 
 mng.send()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d31100aa/examples/python/selected_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/selected_recv.py b/examples/python/selected_recv.py
index 2ea704b..dc062d5 100755
--- a/examples/python/selected_recv.py
+++ b/examples/python/selected_recv.py
@@ -28,7 +28,7 @@ class Recv(MessagingHandler):
 
     def on_start(self, event):
         conn = event.container.connect("localhost:5672")
-        event.container.create_receiver(conn, "examples", options=Selector(u"colour = 'green'"))
+        event.container.create_receiver(conn, "examples", options=Selector("colour = 'green'"))
 
     def on_message(self, event):
         print(event.message.body)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d31100aa/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index dd32648..b792c37 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -211,7 +211,7 @@ class EventInjector(object):
         of the reactor to which this EventInjector was added.
         """
         self.queue.put(event)
-        os.write(self.pipe[1], "!")
+        os.write(self.pipe[1], six.b("!"))
 
     def close(self):
         """


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[04/34] qpid-proton git commit: PROTON-490: port mllib document parser to Python 3

Posted by kg...@apache.org.
PROTON-490: port mllib document parser to Python 3

Ported from the original patch supplied by Mickael Maison.  Uses the
six compatibility library.


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

Branch: refs/heads/master
Commit: 5d7a458635eb55167e33875e040b8147230c4c1b
Parents: 979471f
Author: Ken Giusti <kg...@apache.org>
Authored: Mon Apr 20 11:55:27 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Apr 20 13:04:56 2015 -0400

----------------------------------------------------------------------
 proton-c/mllib/__init__.py   | 23 ++++-------------------
 proton-c/mllib/dom.py        |  7 ++++---
 proton-c/mllib/parsers.py    | 37 ++-----------------------------------
 proton-c/mllib/transforms.py |  2 +-
 4 files changed, 11 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7a4586/proton-c/mllib/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/__init__.py b/proton-c/mllib/__init__.py
index c6fccf1..9e78a87 100644
--- a/proton-c/mllib/__init__.py
+++ b/proton-c/mllib/__init__.py
@@ -18,8 +18,7 @@
 #
 
 """
-This module provides document parsing and transformation utilities for
-both SGML and XML.
+This module provides document parsing and transformation utilities for XML.
 """
 
 from __future__ import absolute_import
@@ -28,7 +27,8 @@ import os, sys
 import xml.sax, types
 from xml.sax.handler import ErrorHandler
 from xml.sax.xmlreader import InputSource
-from cStringIO import StringIO
+import six
+from six.moves import cStringIO as StringIO
 
 from . import dom
 from . import transforms
@@ -37,26 +37,11 @@ from . import parsers
 def transform(node, *args):
   result = node
   for t in args:
-    if isinstance(t, type):
+    if isinstance(t, six.class_types):
       t = t()
     result = result.dispatch(t)
   return result
 
-def sgml_parse(source):
-  if isinstance(source, basestring):
-    source = StringIO(source)
-    fname = "<string>"
-  elif hasattr(source, "name"):
-    fname = source.name
-  p = parsers.SGMLParser()
-  num = 1
-  for line in source:
-    p.feed(line)
-    p.parser.line(fname, num, None)
-    num += 1
-  p.close()
-  return p.parser.tree
-
 class Resolver:
 
   def __init__(self, path):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7a4586/proton-c/mllib/dom.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/dom.py b/proton-c/mllib/dom.py
index 4cbac26..b6ca27d 100644
--- a/proton-c/mllib/dom.py
+++ b/proton-c/mllib/dom.py
@@ -26,6 +26,7 @@ from __future__ import generators
 from __future__ import nested_scopes
 from __future__ import absolute_import
 
+import six
 
 class Container:
 
@@ -178,7 +179,7 @@ class Leaf(Component, Dispatcher):
   base = None
 
   def __init__(self, data):
-    assert isinstance(data, basestring)
+    assert isinstance(data, six.string_types)
     self.data = data
 
 class Data(Leaf):
@@ -268,7 +269,7 @@ class Values(View):
       yield value
 
 def flatten_path(path):
-  if isinstance(path, basestring):
+  if isinstance(path, six.string_types):
     for part in path.split("/"):
       yield part
   elif callable(path):
@@ -291,7 +292,7 @@ class Query(View):
         select = Query
         pred = p
         source = query
-      elif isinstance(p, basestring):
+      elif isinstance(p, six.string_types):
         if p[0] == "@":
           select = Values
           pred = lambda x, n=p[1:]: x[0] == n

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7a4586/proton-c/mllib/parsers.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/parsers.py b/proton-c/mllib/parsers.py
index e71018d..72d44ab 100644
--- a/proton-c/mllib/parsers.py
+++ b/proton-c/mllib/parsers.py
@@ -18,11 +18,11 @@
 #
 
 """
-Parsers for SGML and XML to dom.
+Parsers for XML to dom.
 """
 from __future__ import absolute_import
 
-import sgmllib, xml.sax.handler
+import xml.sax.handler
 from .dom import *
 
 class Parser:
@@ -74,39 +74,6 @@ class Parser:
       self.node = self.node.parent
 
 
-class SGMLParser(sgmllib.SGMLParser):
-
-  def __init__(self, entitydefs = None):
-    sgmllib.SGMLParser.__init__(self)
-    if entitydefs == None:
-      self.entitydefs = {}
-    else:
-      self.entitydefs = entitydefs
-    self.parser = Parser()
-
-  def unknown_starttag(self, name, attrs):
-    self.parser.start(name, attrs)
-
-  def handle_data(self, data):
-    self.parser.data(data)
-
-  def handle_comment(self, comment):
-    self.parser.comment(comment)
-
-  def unknown_entityref(self, ref):
-    self.parser.entity(ref)
-
-  def unknown_charref(self, ref):
-    self.parser.character(ref)
-
-  def unknown_endtag(self, name):
-    self.parser.end(name)
-
-  def close(self):
-    sgmllib.SGMLParser.close(self)
-    self.parser.balance()
-    assert self.parser.node == self.parser.tree
-
 class XMLParser(xml.sax.handler.ContentHandler):
 
   def __init__(self):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7a4586/proton-c/mllib/transforms.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/transforms.py b/proton-c/mllib/transforms.py
index 383add3..43e9ef2 100644
--- a/proton-c/mllib/transforms.py
+++ b/proton-c/mllib/transforms.py
@@ -23,7 +23,7 @@ Useful transforms for dom objects.
 from __future__ import absolute_import
 
 from . import dom
-from cStringIO import StringIO
+from six.moves import cStringIO as StringIO
 
 class Visitor:
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[28/34] qpid-proton git commit: Merge branch 'master' into kgiusti-python3

Posted by kg...@apache.org.
Merge branch 'master' into kgiusti-python3


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

Branch: refs/heads/master
Commit: 6069e1f4e974f261f23bbf45543733d9db003e7e
Parents: dff246b 98e27c6
Author: Ken Giusti <kg...@apache.org>
Authored: Thu Jun 18 13:55:06 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Thu Jun 18 13:55:06 2015 -0400

----------------------------------------------------------------------
 .travis.yml                                 |  12 +-
 proton-c/bindings/python/proton/__init__.py |   7 +-
 proton-c/bindings/ruby/CMakeLists.txt       |  18 ++-
 proton-c/include/proton/cproton.i           |   2 -
 proton-c/include/proton/transport.h         |  16 +-
 proton-c/src/engine/engine-internal.h       |  14 +-
 proton-c/src/engine/engine.c                |  16 +-
 proton-c/src/messenger/messenger.c          |   5 +-
 proton-c/src/sasl/cyrus_sasl.c              |   2 +-
 proton-c/src/sasl/sasl.c                    |   2 +-
 proton-c/src/transport/transport.c          | 124 +++++++++++++--
 tests/python/proton_tests/engine.py         |  48 +++++-
 tests/python/proton_tests/transport.py      | 190 +++++++++++++++++++++--
 13 files changed, 418 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6069e1f4/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6069e1f4/tests/python/proton_tests/engine.py
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6069e1f4/tests/python/proton_tests/transport.py
----------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[02/34] qpid-proton git commit: PROTON-490: futurize examples

Posted by kg...@apache.org.
PROTON-490: futurize examples


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

Branch: refs/heads/master
Commit: aae1d20a42dcaded08b8daec4cf43bd5e1fde970
Parents: 677729a
Author: Ken Giusti <kg...@apache.org>
Authored: Thu Apr 16 14:57:08 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Apr 20 12:46:20 2015 -0400

----------------------------------------------------------------------
 examples/python/abstract_server.py             |  3 ++-
 examples/python/client.py                      |  3 ++-
 examples/python/client_http.py                 |  3 ++-
 examples/python/db_ctrl.py                     |  7 ++++---
 examples/python/db_recv.py                     |  3 ++-
 examples/python/db_send.py                     | 11 ++++++-----
 examples/python/direct_recv.py                 |  3 ++-
 examples/python/direct_send.py                 |  3 ++-
 examples/python/helloworld.py                  |  3 ++-
 examples/python/helloworld_blocking.py         |  3 ++-
 examples/python/helloworld_direct.py           |  3 ++-
 examples/python/helloworld_direct_tornado.py   |  3 ++-
 examples/python/helloworld_tornado.py          |  3 ++-
 examples/python/messenger/async.py             |  3 ++-
 examples/python/messenger/client.py            |  7 ++++---
 examples/python/messenger/recv.py              |  7 ++++---
 examples/python/messenger/recv_async.py        | 11 ++++++-----
 examples/python/messenger/send.py              |  3 ++-
 examples/python/messenger/send_async.py        |  9 +++++----
 examples/python/messenger/server.py            |  5 +++--
 examples/python/proton_server.py               |  3 ++-
 examples/python/queue_browser.py               |  3 ++-
 examples/python/reactor/cat.py                 |  3 ++-
 examples/python/reactor/count-randomly.py      |  9 +++++----
 examples/python/reactor/counter.py             |  7 ++++---
 examples/python/reactor/delegates.py           |  5 +++--
 examples/python/reactor/echo.py                |  5 +++--
 examples/python/reactor/global-logger.py       |  9 +++++----
 examples/python/reactor/goodbye-world.py       |  5 +++--
 examples/python/reactor/handlers.py            |  7 ++++---
 examples/python/reactor/hello-world.py         |  3 ++-
 examples/python/reactor/reactor-logger.py      |  7 ++++---
 examples/python/reactor/recv.py                |  3 ++-
 examples/python/reactor/scheduling.py          |  7 ++++---
 examples/python/reactor/tornado-hello-world.py |  3 ++-
 examples/python/reactor/unhandled.py           |  3 ++-
 examples/python/recurring_timer.py             |  5 +++--
 examples/python/recurring_timer_tornado.py     |  5 +++--
 examples/python/selected_recv.py               |  3 ++-
 examples/python/server.py                      |  5 +++--
 examples/python/server_direct.py               |  7 ++++---
 examples/python/server_tx.py                   |  5 +++--
 examples/python/simple_recv.py                 |  3 ++-
 examples/python/simple_send.py                 |  3 ++-
 examples/python/sync_client.py                 |  3 ++-
 examples/python/tx_recv.py                     |  3 ++-
 examples/python/tx_recv_interactive.py         | 11 ++++++-----
 examples/python/tx_send.py                     |  3 ++-
 48 files changed, 141 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/abstract_server.py
----------------------------------------------------------------------
diff --git a/examples/python/abstract_server.py b/examples/python/abstract_server.py
index 2d0de32..fed7fb2 100755
--- a/examples/python/abstract_server.py
+++ b/examples/python/abstract_server.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton_server import Server
 
 class Application(Server):
@@ -27,7 +28,7 @@ class Application(Server):
     def on_request(self, request, reply_to):
         response = request.upper()
         self.send(response, reply_to)
-        print "Request from: %s" % reply_to
+        print("Request from: %s" % reply_to)
 
 try:
     Application("localhost:5672", "examples").run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/client.py
----------------------------------------------------------------------
diff --git a/examples/python/client.py b/examples/python/client.py
index a116175..18dc81a 100755
--- a/examples/python/client.py
+++ b/examples/python/client.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton import Message
 from proton.handlers import MessagingHandler
@@ -43,7 +44,7 @@ class Client(MessagingHandler):
             self.next_request()
 
     def on_message(self, event):
-        print "%s => %s" % (self.requests.pop(0), event.message.body)
+        print("%s => %s" % (self.requests.pop(0), event.message.body))
         if self.requests:
             self.next_request()
         else:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/client_http.py
----------------------------------------------------------------------
diff --git a/examples/python/client_http.py b/examples/python/client_http.py
index cd0d63f..bf65639 100755
--- a/examples/python/client_http.py
+++ b/examples/python/client_http.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import tornado.ioloop
 import tornado.web
 from proton import Message
@@ -51,7 +52,7 @@ class Client(MessagingHandler):
     def on_message(self, event):
         if self.sent:
             request, handler = self.sent.pop(0)
-            print "%s => %s" % (request, event.message.body)
+            print("%s => %s" % (request, event.message.body))
             handler(event.message.body)
             self.do_request()
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/db_ctrl.py
----------------------------------------------------------------------
diff --git a/examples/python/db_ctrl.py b/examples/python/db_ctrl.py
index b28e0eb..04770ce 100755
--- a/examples/python/db_ctrl.py
+++ b/examples/python/db_ctrl.py
@@ -18,11 +18,12 @@
 # under the License.
 #
 
+from __future__ import print_function
 import sqlite3
 import sys
 
 if len(sys.argv) < 3:
-    print "Usage: %s [init|insert|list] db" % sys.argv[0]
+    print("Usage: %s [init|insert|list] db" % sys.argv[0])
 else:
     conn = sqlite3.connect(sys.argv[2])
     with conn:
@@ -35,7 +36,7 @@ else:
             cursor.execute("SELECT * FROM records")
             rows = cursor.fetchall()
             for r in rows:
-                print r
+                print(r)
         elif sys.argv[1] == "insert":
             while True:
                 l = sys.stdin.readline()
@@ -43,4 +44,4 @@ else:
                 conn.execute("INSERT INTO records(description) VALUES (?)", (l.rstrip(),))
             conn.commit()
         else:
-            print "Unrecognised command: %s" %  sys.argv[1]
+            print("Unrecognised command: %s" %  sys.argv[1])

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/db_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/db_recv.py b/examples/python/db_recv.py
index d8dd7bc..8c79049 100755
--- a/examples/python/db_recv.py
+++ b/examples/python/db_recv.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton.handlers import MessagingHandler
 from proton.reactor import ApplicationEvent, Container, EventInjector
@@ -58,7 +59,7 @@ class Recv(MessagingHandler):
                 self.received += 1
                 self.last_id = id
                 self.db.insert(id, event.message.body, ApplicationEvent("record_inserted", delivery=event.delivery))
-                print "inserted message %s" % id
+                print("inserted message %s" % id)
             else:
                 self.release(event.delivery)
         else:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/db_send.py
----------------------------------------------------------------------
diff --git a/examples/python/db_send.py b/examples/python/db_send.py
index 6464fa6..99558d5 100755
--- a/examples/python/db_send.py
+++ b/examples/python/db_send.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 import Queue
 import time
@@ -49,7 +50,7 @@ class Send(MessagingHandler):
     def on_records_loaded(self, event):
         if self.records.empty():
             if event.subject == self.load_count:
-                print "Exhausted available data, waiting to recheck..."
+                print("Exhausted available data, waiting to recheck...")
                 # check for new data after 5 seconds
                 self.container.schedule(5, self)
         else:
@@ -57,7 +58,7 @@ class Send(MessagingHandler):
 
     def request_records(self):
         if not self.records.full():
-            print "loading records..."
+            print("loading records...")
             self.load_count += 1
             self.db.load(self.records, event=ApplicationEvent("records_loaded", link=self.sender, subject=self.load_count))
 
@@ -71,13 +72,13 @@ class Send(MessagingHandler):
             id = record['id']
             self.sender.send(Message(id=id, durable=True, body=record['description']), tag=str(id))
             self.sent += 1
-            print "sent message %s" % id
+            print("sent message %s" % id)
         self.request_records()
 
     def on_settled(self, event):
         id = int(event.delivery.tag)
         self.db.delete(id)
-        print "settled message %s" % id
+        print("settled message %s" % id)
         self.confirmed += 1
         if self.confirmed == self.target:
             event.connection.close()
@@ -88,7 +89,7 @@ class Send(MessagingHandler):
         self.sent = self.confirmed
 
     def on_timer_task(self, event):
-        print "Rechecking for data..."
+        print("Rechecking for data...")
         self.request_records()
 
 parser = optparse.OptionParser(usage="usage: %prog [options]",

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/direct_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/direct_recv.py b/examples/python/direct_recv.py
index 92f712c..1c6bf36 100755
--- a/examples/python/direct_recv.py
+++ b/examples/python/direct_recv.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -37,7 +38,7 @@ class Recv(MessagingHandler):
             # ignore duplicate message
             return
         if self.expected == 0 or self.received < self.expected:
-            print event.message.body
+            print(event.message.body)
             self.received += 1
             if self.received == self.expected:
                 event.receiver.close()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/direct_send.py
----------------------------------------------------------------------
diff --git a/examples/python/direct_send.py b/examples/python/direct_send.py
index 0bfad17..f551e1e 100755
--- a/examples/python/direct_send.py
+++ b/examples/python/direct_send.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton import Message
 from proton.handlers import MessagingHandler
@@ -43,7 +44,7 @@ class Send(MessagingHandler):
     def on_accepted(self, event):
         self.confirmed += 1
         if self.confirmed == self.total:
-            print "all messages confirmed"
+            print("all messages confirmed")
             event.connection.close()
             self.acceptor.close()
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/helloworld.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld.py b/examples/python/helloworld.py
index d741f5e..d73a4cb 100755
--- a/examples/python/helloworld.py
+++ b/examples/python/helloworld.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -38,7 +39,7 @@ class HelloWorld(MessagingHandler):
         event.sender.close()
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
         event.connection.close()
 
 Container(HelloWorld("localhost:5672", "examples")).run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/helloworld_blocking.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_blocking.py b/examples/python/helloworld_blocking.py
index 62b6105..049f148 100755
--- a/examples/python/helloworld_blocking.py
+++ b/examples/python/helloworld_blocking.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.utils import BlockingConnection
 from proton.handlers import IncomingMessageHandler
@@ -27,7 +28,7 @@ receiver = conn.create_receiver("examples")
 sender = conn.create_sender("examples")
 sender.send(Message(body=u"Hello World!"));
 msg = receiver.receive(timeout=30)
-print msg.body
+print(msg.body)
 receiver.accept()
 conn.close()
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/helloworld_direct.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_direct.py b/examples/python/helloworld_direct.py
index 2ad78a7..d6374a2 100755
--- a/examples/python/helloworld_direct.py
+++ b/examples/python/helloworld_direct.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -36,7 +37,7 @@ class HelloWorld(MessagingHandler):
         event.sender.close()
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
 
     def on_accepted(self, event):
         event.connection.close()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/helloworld_direct_tornado.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_direct_tornado.py b/examples/python/helloworld_direct_tornado.py
index 2466f80..9ef2ed7 100755
--- a/examples/python/helloworld_direct_tornado.py
+++ b/examples/python/helloworld_direct_tornado.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton_tornado import Container
@@ -36,7 +37,7 @@ class HelloWorld(MessagingHandler):
         event.sender.close()
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
 
     def on_accepted(self, event):
         event.connection.close()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/helloworld_tornado.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_tornado.py b/examples/python/helloworld_tornado.py
index d4b32cf..3cb2ad1 100755
--- a/examples/python/helloworld_tornado.py
+++ b/examples/python/helloworld_tornado.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton_tornado import Container
@@ -38,7 +39,7 @@ class HelloWorld(MessagingHandler):
         event.sender.close()
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
         event.connection.close()
 
 Container(HelloWorld("localhost:5672", "examples")).run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/async.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/async.py b/examples/python/messenger/async.py
index 14fc4c9..b3f5c45 100755
--- a/examples/python/messenger/async.py
+++ b/examples/python/messenger/async.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys
 from proton import *
 
@@ -72,7 +73,7 @@ class CallbackAdapter:
                 self.messenger.accept(t)
             except:
                 ex = sys.exc_info()[1]
-                print "Exception:", ex
+                print("Exception:", ex)
                 self.messenger.reject(t)
 
     def send(self, message, on_status=None):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/client.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/client.py b/examples/python/messenger/client.py
index 3146e45..62fc16e 100755
--- a/examples/python/messenger/client.py
+++ b/examples/python/messenger/client.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from proton import *
 
@@ -48,8 +49,8 @@ if opts.reply_to[:2] == "~/":
   mng.recv(1)
   try:
     mng.get(msg)
-    print msg.address, msg.subject
-  except Exception, e:
-    print e
+    print(msg.address, msg.subject)
+  except Exception as e:
+    print(e)
 
 mng.stop()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/recv.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/recv.py b/examples/python/messenger/recv.py
index e19ddad..5771bd7 100755
--- a/examples/python/messenger/recv.py
+++ b/examples/python/messenger/recv.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from proton import *
 
@@ -46,9 +47,9 @@ while True:
   while mng.incoming:
     try:
       mng.get(msg)
-    except Exception, e:
-      print e
+    except Exception as e:
+      print(e)
     else:
-      print msg.address, msg.subject or "(no subject)", msg.properties, msg.body
+      print(msg.address, msg.subject or "(no subject)", msg.properties, msg.body)
 
 mng.stop()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/recv_async.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/recv_async.py b/examples/python/messenger/recv_async.py
index ba4f063..b38c31a 100755
--- a/examples/python/messenger/recv_async.py
+++ b/examples/python/messenger/recv_async.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from async import *
 
@@ -31,25 +32,25 @@ if not args:
 class App(CallbackAdapter):
 
     def on_start(self):
-        print "Started"
+        print("Started")
         for a in args:
-            print "Subscribing to:", a
+            print("Subscribing to:", a)
             self.messenger.subscribe(a)
         self.messenger.recv()
 
     def on_recv(self, msg):
-        print "Received:", msg
+        print("Received:", msg)
         if msg.body == "die":
             self.stop()
         if msg.reply_to:
             self.message.clear()
             self.message.address = msg.reply_to
             self.message.body = "Reply for: %s" % msg.body
-            print "Replied:", self.message
+            print("Replied:", self.message)
             self.send(self.message)
 
     def on_stop(self):
-        print "Stopped"
+        print("Stopped")
 
 a = App(Messenger())
 a.run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/send.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/send.py b/examples/python/messenger/send.py
index 139f6e8..f40e7b1 100755
--- a/examples/python/messenger/send.py
+++ b/examples/python/messenger/send.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from proton import *
 
@@ -39,6 +40,6 @@ for m in args:
   mng.put(msg)
 
 mng.send()
-print "sent:", ", ".join(args)
+print("sent:", ", ".join(args))
 
 mng.stop()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/send_async.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/send_async.py b/examples/python/messenger/send_async.py
index 304aceb..50f7a68 100755
--- a/examples/python/messenger/send_async.py
+++ b/examples/python/messenger/send_async.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from async import *
 
@@ -33,7 +34,7 @@ if not args:
 class App(CallbackAdapter):
 
     def on_start(self):
-        print "Started"
+        print("Started")
         self.message.clear()
         self.message.address = opts.address
         self.message.reply_to = opts.reply_to
@@ -45,19 +46,19 @@ class App(CallbackAdapter):
             self.messenger.recv()
 
     def on_status(self, status):
-        print "Status:", status
+        print("Status:", status)
         if not opts.reply_to or opts.reply_to[0] != "~":
             args.pop(0)
             if not args: self.stop()
 
     def on_recv(self, msg):
-        print "Received:", msg
+        print("Received:", msg)
         if opts.reply_to and opts.reply_to[0] == "~":
             args.pop(0)
             if not args: self.stop()
 
     def on_stop(self):
-        print "Stopped"
+        print("Stopped")
 
 a = App(Messenger())
 a.run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/server.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/server.py b/examples/python/messenger/server.py
index 01196be..8c25879 100755
--- a/examples/python/messenger/server.py
+++ b/examples/python/messenger/server.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import sys, optparse
 from proton import *
 
@@ -38,7 +39,7 @@ def dispatch(request, response):
   if request.subject:
     response.subject = "Re: %s" % request.subject
   response.properties = request.properties
-  print "Dispatched %s %s" % (request.subject, request.properties)
+  print("Dispatched %s %s" % (request.subject, request.properties))
 
 msg = Message()
 reply = Message()
@@ -50,7 +51,7 @@ while True:
   if mng.incoming > 0:
     mng.get(msg)
     if msg.reply_to:
-      print msg.reply_to
+      print(msg.reply_to)
       reply.address = msg.reply_to
       reply.correlation_id = msg.correlation_id
       reply.body = msg.body

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/proton_server.py
----------------------------------------------------------------------
diff --git a/examples/python/proton_server.py b/examples/python/proton_server.py
index b92261c..c2520c1 100755
--- a/examples/python/proton_server.py
+++ b/examples/python/proton_server.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -38,7 +39,7 @@ class Server(MessagingHandler):
             self.relay = self.container.create_sender(self.conn, None)
 
     def on_connection_close(self, endpoint, error):
-        if error: print "Closed due to %s" % error
+        if error: print("Closed due to %s" % error)
         self.conn.close()
 
     def run(self):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/queue_browser.py
----------------------------------------------------------------------
diff --git a/examples/python/queue_browser.py b/examples/python/queue_browser.py
index ad4d393..34d2377 100755
--- a/examples/python/queue_browser.py
+++ b/examples/python/queue_browser.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton.reactor import Container, Copy
 from proton.handlers import MessagingHandler
 
@@ -30,7 +31,7 @@ class Recv(MessagingHandler):
         event.container.create_receiver(conn, "examples", options=Copy())
 
     def on_message(self, event):
-        print event.message
+        print(event.message)
         if event.receiver.queued == 0 and event.receiver.drained:
             event.connection.close()
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/cat.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/cat.py b/examples/python/reactor/cat.py
index 57f4515..82ebd27 100755
--- a/examples/python/reactor/cat.py
+++ b/examples/python/reactor/cat.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import sys, os
 from proton.reactor import Reactor
 
@@ -42,7 +43,7 @@ class Echo:
         # to be read, or the end of stream has been reached.
         data = os.read(sel.fileno(), 1024)
         if data:
-            print data,
+            print(data, end=' ')
         else:
             sel.terminate()
             event.reactor.update(sel)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/count-randomly.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/count-randomly.py b/examples/python/reactor/count-randomly.py
index d9a32c6..fb3709a 100755
--- a/examples/python/reactor/count-randomly.py
+++ b/examples/python/reactor/count-randomly.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time, random
 from proton.reactor import Reactor
 
@@ -34,7 +35,7 @@ class Counter:
 
     def on_timer_task(self, event):
         self.count += 1
-        print self.count
+        print(self.count)
         if not self.done():
             event.reactor.schedule(0.25, self)
 
@@ -46,7 +47,7 @@ class Program:
 
     def on_reactor_init(self, event):
         self.start = time.time()
-        print "Hello, World!"
+        print("Hello, World!")
 
         # Save the counter instance in an attribute so we can refer to
         # it later.
@@ -60,12 +61,12 @@ class Program:
 
     def on_timer_task(self, event):
         # keep on shouting until we are done counting
-        print "Yay, %s!" % random.randint(10, 100)
+        print("Yay, %s!" % random.randint(10, 100))
         if not self.counter.done():
             event.reactor.schedule(0.5, self)
 
     def on_reactor_final(self, event):
-        print "Goodbye, World! (after %s long seconds)" % (time.time() - self.start)
+        print("Goodbye, World! (after %s long seconds)" % (time.time() - self.start))
 
 # In hello-world.py we said the reactor exits when there are no more
 # events to process. While this is true, it's not actually complete.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/counter.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/counter.py b/examples/python/reactor/counter.py
index 1ef45f0..7c8167a 100755
--- a/examples/python/reactor/counter.py
+++ b/examples/python/reactor/counter.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
@@ -29,7 +30,7 @@ class Counter:
 
     def on_timer_task(self, event):
         self.count += 1
-        print self.count
+        print(self.count)
         if self.count < self.limit:
             # A recurring task can be acomplished by just scheduling
             # another event.
@@ -39,7 +40,7 @@ class Program:
 
     def on_reactor_init(self, event):
         self.start = time.time()
-        print "Hello, World!"
+        print("Hello, World!")
 
         # Note that unlike the previous scheduling example, we pass in
         # a separate object for the handler. This means that the timer
@@ -48,7 +49,7 @@ class Program:
         event.reactor.schedule(0.25, Counter(10))
 
     def on_reactor_final(self, event):
-        print "Goodbye, World! (after %s long seconds)" % (time.time() - self.start)
+        print("Goodbye, World! (after %s long seconds)" % (time.time() - self.start))
 
 # In hello-world.py we said the reactor exits when there are no more
 # events to process. While this is true, it's not actually complete.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/delegates.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/delegates.py b/examples/python/reactor/delegates.py
index 813ceba..1a8e1e9 100755
--- a/examples/python/reactor/delegates.py
+++ b/examples/python/reactor/delegates.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
@@ -28,12 +29,12 @@ from proton.reactor import Reactor
 class Hello:
 
     def on_reactor_init(self, event):
-        print "Hello, World!"
+        print("Hello, World!")
 
 class Goodbye:
 
     def on_reactor_final(self, event):
-        print "Goodbye, World!"
+        print("Goodbye, World!")
 
 class Program:
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/echo.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/echo.py b/examples/python/reactor/echo.py
index 4675f5d..17529d9 100755
--- a/examples/python/reactor/echo.py
+++ b/examples/python/reactor/echo.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import sys, os
 from proton.reactor import Reactor
 
@@ -42,7 +43,7 @@ class Echo:
         # to be read, or the end of stream has been reached.
         data = os.read(sel.fileno(), 1024)
         if data:
-            print data,
+            print(data, end=' ')
         else:
             sel.terminate()
             event.reactor.update(sel)
@@ -54,7 +55,7 @@ class Program:
         # selectable stays alive until it reads the end of stream
         # marker. This will keep the whole reactor running until we
         # type Control-D.
-        print "Type whatever you want and then use Control-D to exit:"
+        print("Type whatever you want and then use Control-D to exit:")
         event.reactor.selectable(Echo(sys.stdin))
 
 r = Reactor(Program())

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/global-logger.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/global-logger.py b/examples/python/reactor/global-logger.py
index bc3bc56..3cbe11c 100755
--- a/examples/python/reactor/global-logger.py
+++ b/examples/python/reactor/global-logger.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
@@ -30,21 +31,21 @@ from proton.reactor import Reactor
 class Logger:
 
     def on_unhandled(self, name, event):
-        print "LOG:", name, event
+        print("LOG:", name, event)
 
 class Task:
 
     def on_timer_task(self, event):
-        print "Mission accomplished!"
+        print("Mission accomplished!")
 
 class Program:
 
     def on_reactor_init(self, event):
-        print "Hello, World!"
+        print("Hello, World!")
         event.reactor.schedule(0, Task())
 
     def on_reactor_final(self, event):
-        print "Goodbye, World!"
+        print("Goodbye, World!")
 
 r = Reactor(Program())
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/goodbye-world.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/goodbye-world.py b/examples/python/reactor/goodbye-world.py
index 44bcf7c..f251c8a 100755
--- a/examples/python/reactor/goodbye-world.py
+++ b/examples/python/reactor/goodbye-world.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton.reactor import Reactor
 
 # So far the reactive hello-world doesn't look too different from a
@@ -30,7 +31,7 @@ class Program:
 
     # As before we handle the reactor init event.
     def on_reactor_init(self, event):
-        print "Hello, World!"
+        print("Hello, World!")
 
     # In addition to an initial event, the reactor also produces an
     # event when it is about to exit. This may not behave much
@@ -40,7 +41,7 @@ class Program:
     # regardless of what other paths the main logic of our program
     # might take.
     def on_reactor_final(self, event):
-        print "Goodbye, World!"
+        print("Goodbye, World!")
 
 r = Reactor(Program())
 r.run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/handlers.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/handlers.py b/examples/python/reactor/handlers.py
index ed3a94d..ee8d807 100755
--- a/examples/python/reactor/handlers.py
+++ b/examples/python/reactor/handlers.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
@@ -25,12 +26,12 @@ from proton.reactor import Reactor
 class World:
 
     def on_reactor_init(self, event):
-        print "World!"
+        print("World!")
 
 class Goodbye:
 
     def on_reactor_final(self, event):
-        print "Goodbye, World!"
+        print("Goodbye, World!")
 
 class Hello:
 
@@ -42,7 +43,7 @@ class Hello:
 
     # The parent handler always receives the event first.
     def on_reactor_init(self, event):
-        print "Hello",
+        print("Hello", end=' ')
 
 r = Reactor(Hello())
 r.run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/hello-world.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/hello-world.py b/examples/python/reactor/hello-world.py
index c685c73..f1708db 100755
--- a/examples/python/reactor/hello-world.py
+++ b/examples/python/reactor/hello-world.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton.reactor import Reactor
 
 # The proton reactor provides a general purpose event processing
@@ -31,7 +32,7 @@ class Program:
     # The reactor init event is produced by the reactor itself when it
     # starts.
     def on_reactor_init(self, event):
-        print "Hello, World!"
+        print("Hello, World!")
 
 # When you construct a reactor, you give it a handler.
 r = Reactor(Program())

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/reactor-logger.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/reactor-logger.py b/examples/python/reactor/reactor-logger.py
index c07e9b9..2d3f9de 100755
--- a/examples/python/reactor/reactor-logger.py
+++ b/examples/python/reactor/reactor-logger.py
@@ -18,21 +18,22 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
 class Logger:
 
     def on_unhandled(self, name, event):
-        print "LOG:", name, event
+        print("LOG:", name, event)
 
 class Program:
 
     def on_reactor_init(self, event):
-        print "Hello, World!"
+        print("Hello, World!")
 
     def on_reactor_final(self, event):
-        print "Goodbye, World!"
+        print("Goodbye, World!")
 
 # You can pass multiple handlers to a reactor when you construct it.
 # Each of these handlers will see every event the reactor sees. By

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/recv.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/recv.py b/examples/python/reactor/recv.py
index aa56472..c6f07f1 100755
--- a/examples/python/reactor/recv.py
+++ b/examples/python/reactor/recv.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.reactor import Reactor
 from proton.handlers import CHandshaker, CFlowController
@@ -41,7 +42,7 @@ class Program:
         # compliment the similar thing on send
         rcv = event.receiver
         if rcv and self.message.recv(rcv):
-            print self.message
+            print(self.message)
             event.delivery.settle()
 
 r = Reactor(Program())

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/scheduling.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/scheduling.py b/examples/python/reactor/scheduling.py
index f822f68..8956821 100755
--- a/examples/python/reactor/scheduling.py
+++ b/examples/python/reactor/scheduling.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
@@ -25,7 +26,7 @@ class Program:
 
     def on_reactor_init(self, event):
         self.start = time.time()
-        print "Hello, World!"
+        print("Hello, World!")
 
         # We can schedule a task event for some point in the future.
         # This will cause the reactor to stick around until it has a
@@ -42,10 +43,10 @@ class Program:
 
     def on_timer_task(self, event):
         task = event.context # xxx: don't have a task property on event yet
-        print task.something_to_say, "my task is complete!"
+        print(task.something_to_say, "my task is complete!")
 
     def on_reactor_final(self, event):
-        print "Goodbye, World! (after %s long seconds)" % (time.time() - self.start)
+        print("Goodbye, World! (after %s long seconds)" % (time.time() - self.start))
 
 r = Reactor(Program())
 r.run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/tornado-hello-world.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/tornado-hello-world.py b/examples/python/reactor/tornado-hello-world.py
index fa8ca83..d06cd1b 100755
--- a/examples/python/reactor/tornado-hello-world.py
+++ b/examples/python/reactor/tornado-hello-world.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import tornado.ioloop
 from tornado_app import TornadoApp
 
@@ -32,7 +33,7 @@ class Program:
     # The reactor init event is produced by the reactor itself when it
     # starts.
     def on_reactor_init(self, event):
-        print "Hello, World!"
+        print("Hello, World!")
 
 # The TornadoApp integrates a Reactor into tornado's ioloop.
 TornadoApp(Program())

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/unhandled.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/unhandled.py b/examples/python/reactor/unhandled.py
index 3734a71..9ab2212 100755
--- a/examples/python/reactor/unhandled.py
+++ b/examples/python/reactor/unhandled.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Reactor
 
@@ -28,7 +29,7 @@ class Program:
     # if it exists. This can be useful not only for debugging, but for
     # logging and for delegating/inheritance.
     def on_unhandled(self, name, event):
-        print name, event
+        print(name, event)
 
 r = Reactor(Program())
 r.run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/recurring_timer.py
----------------------------------------------------------------------
diff --git a/examples/python/recurring_timer.py b/examples/python/recurring_timer.py
index a39791d..b59dbe1 100755
--- a/examples/python/recurring_timer.py
+++ b/examples/python/recurring_timer.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton.reactor import Container, Handler
 
 class Recurring(Handler):
@@ -29,7 +30,7 @@ class Recurring(Handler):
         self.container.schedule(self.period, self)
 
     def on_timer_task(self, event):
-        print "Tick..."
+        print("Tick...")
         self.container.schedule(self.period, self)
 
 try:
@@ -37,6 +38,6 @@ try:
     container.run()
 except KeyboardInterrupt:
     container.stop()
-    print
+    print()
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/recurring_timer_tornado.py
----------------------------------------------------------------------
diff --git a/examples/python/recurring_timer_tornado.py b/examples/python/recurring_timer_tornado.py
index 1f1c0e7..07ebd26 100755
--- a/examples/python/recurring_timer_tornado.py
+++ b/examples/python/recurring_timer_tornado.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 from proton.reactor import Handler
 from proton_tornado import TornadoLoop
@@ -31,7 +32,7 @@ class Recurring(Handler):
         self.container.schedule(time.time() + self.period, subject=self)
 
     def on_timer(self, event):
-        print "Tick..."
+        print("Tick...")
         self.container.schedule(time.time() + self.period, subject=self)
 
 try:
@@ -39,6 +40,6 @@ try:
     container.run()
 except KeyboardInterrupt:
     container.stop()
-    print
+    print()
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/selected_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/selected_recv.py b/examples/python/selected_recv.py
index 351d4ef..2ea704b 100755
--- a/examples/python/selected_recv.py
+++ b/examples/python/selected_recv.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton.reactor import Container, Selector
 from proton.handlers import MessagingHandler
 
@@ -30,7 +31,7 @@ class Recv(MessagingHandler):
         event.container.create_receiver(conn, "examples", options=Selector(u"colour = 'green'"))
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
 
 try:
     Container(Recv()).run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/server.py
----------------------------------------------------------------------
diff --git a/examples/python/server.py b/examples/python/server.py
index 62aa162..3b0a085 100755
--- a/examples/python/server.py
+++ b/examples/python/server.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -30,7 +31,7 @@ class Server(MessagingHandler):
         self.senders = {}
 
     def on_start(self, event):
-        print "Listening on", self.url
+        print("Listening on", self.url)
         self.container = event.container
         self.conn = event.container.connect(self.url)
         self.receiver = event.container.create_receiver(self.conn, self.address)
@@ -41,7 +42,7 @@ class Server(MessagingHandler):
             self.relay = self.container.create_sender(self.conn, None)
 
     def on_message(self, event):
-        print "Received", event.message
+        print("Received", event.message)
         sender = self.relay or self.senders.get(event.message.reply_to)
         if not sender:
             sender = self.container.create_sender(self.conn, event.message.reply_to)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/server_direct.py
----------------------------------------------------------------------
diff --git a/examples/python/server_direct.py b/examples/python/server_direct.py
index 18a20f3..a9910f1 100755
--- a/examples/python/server_direct.py
+++ b/examples/python/server_direct.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import generate_uuid, Message
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -29,7 +30,7 @@ class Server(MessagingHandler):
         self.senders = {}
 
     def on_start(self, event):
-        print "Listening on", self.url
+        print("Listening on", self.url)
         self.container = event.container
         self.acceptor = event.container.listen(self.url)
 
@@ -47,10 +48,10 @@ class Server(MessagingHandler):
             event.link.target.address = event.link.remote_target.address
 
     def on_message(self, event):
-        print "Received", event.message
+        print("Received", event.message)
         sender = self.senders.get(event.message.reply_to)
         if not sender:
-            print "No link for reply"
+            print("No link for reply")
             return
         sender.send(Message(address=event.message.reply_to, body=event.message.body.upper(),
                             correlation_id=event.message.correlation_id))

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/server_tx.py
----------------------------------------------------------------------
diff --git a/examples/python/server_tx.py b/examples/python/server_tx.py
index 96b83cb..51e734c 100755
--- a/examples/python/server_tx.py
+++ b/examples/python/server_tx.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from proton import Message
 from proton.reactor import Container
 from proton.handlers import MessagingHandler, TransactionHandler
@@ -35,10 +36,10 @@ class TxRequest(TransactionHandler):
         event.transaction.commit()
 
     def on_transaction_committed(self, event):
-        print "Request processed successfully"
+        print("Request processed successfully")
 
     def on_transaction_aborted(self, event):
-        print "Request processing aborted"
+        print("Request processing aborted")
 
 
 class TxServer(MessagingHandler):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/simple_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/simple_recv.py b/examples/python/simple_recv.py
index abe30cd..5322500 100755
--- a/examples/python/simple_recv.py
+++ b/examples/python/simple_recv.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -37,7 +38,7 @@ class Recv(MessagingHandler):
             # ignore duplicate message
             return
         if self.expected == 0 or self.received < self.expected:
-            print event.message.body
+            print(event.message.body)
             self.received += 1
             if self.received == self.expected:
                 event.receiver.close()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/simple_send.py
----------------------------------------------------------------------
diff --git a/examples/python/simple_send.py b/examples/python/simple_send.py
index 4158272..75ab550 100755
--- a/examples/python/simple_send.py
+++ b/examples/python/simple_send.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton import Message
 from proton.handlers import MessagingHandler
@@ -43,7 +44,7 @@ class Send(MessagingHandler):
     def on_accepted(self, event):
         self.confirmed += 1
         if self.confirmed == self.total:
-            print "all messages confirmed"
+            print("all messages confirmed")
             event.connection.close()
 
     def on_disconnected(self, event):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/sync_client.py
----------------------------------------------------------------------
diff --git a/examples/python/sync_client.py b/examples/python/sync_client.py
index 82cd85f..95a5650 100755
--- a/examples/python/sync_client.py
+++ b/examples/python/sync_client.py
@@ -23,6 +23,7 @@ Demonstrates the client side of the synchronous request-response pattern
 (also known as RPC or Remote Procecure Call) using proton.
 
 """
+from __future__ import print_function
 
 import optparse
 from proton import Message, Url, ConnectionException, Timeout
@@ -48,7 +49,7 @@ try:
                "And the mome raths outgrabe."]
     for request in REQUESTS:
         response = client.call(Message(body=request))
-        print "%s => %s" % (request, response.body)
+        print("%s => %s" % (request, response.body))
 finally:
     client.connection.close()
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/tx_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/tx_recv.py b/examples/python/tx_recv.py
index 641f0a2..4baddcf 100755
--- a/examples/python/tx_recv.py
+++ b/examples/python/tx_recv.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton import Url
 from proton.reactor import Container
@@ -40,7 +41,7 @@ class TxRecv(MessagingHandler, TransactionHandler):
         self.transaction = None
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
         self.transaction.accept(event.delivery)
         self.current_batch += 1
         if self.current_batch == self.batch_size:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/tx_recv_interactive.py
----------------------------------------------------------------------
diff --git a/examples/python/tx_recv_interactive.py b/examples/python/tx_recv_interactive.py
index d08ff2b..2c1d9a7 100755
--- a/examples/python/tx_recv_interactive.py
+++ b/examples/python/tx_recv_interactive.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import sys
 import threading
 from proton.reactor import ApplicationEvent, Container
@@ -35,19 +36,19 @@ class TxRecv(MessagingHandler, TransactionHandler):
         self.transaction = None
 
     def on_message(self, event):
-        print event.message.body
+        print(event.message.body)
         self.transaction.accept(event.delivery)
 
     def on_transaction_declared(self, event):
         self.transaction = event.transaction
-        print "transaction declared"
+        print("transaction declared")
 
     def on_transaction_committed(self, event):
-        print "transaction committed"
+        print("transaction committed")
         self.container.declare_transaction(self.conn, handler=self)
 
     def on_transaction_aborted(self, event):
-        print "transaction aborted"
+        print("transaction aborted")
         self.container.declare_transaction(self.conn, handler=self)
 
     def on_commit(self, event):
@@ -71,7 +72,7 @@ try:
     thread.daemon=True
     thread.start()
 
-    print "Enter 'fetch', 'commit' or 'abort'"
+    print("Enter 'fetch', 'commit' or 'abort'")
     while True:
         line = sys.stdin.readline()
         if line:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/tx_send.py
----------------------------------------------------------------------
diff --git a/examples/python/tx_send.py b/examples/python/tx_send.py
index 0f1da5a..5e30174 100755
--- a/examples/python/tx_send.py
+++ b/examples/python/tx_send.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from proton import Message, Url
 from proton.reactor import Container
@@ -64,7 +65,7 @@ class TxSend(MessagingHandler, TransactionHandler):
     def on_transaction_committed(self, event):
         self.committed += self.current_batch
         if self.committed == self.total:
-            print "all messages committed"
+            print("all messages committed")
             event.connection.close()
         else:
             self.current_batch = 0


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[10/34] qpid-proton git commit: PROTON-490: port python C wrapper to Python 3

Posted by kg...@apache.org.
PROTON-490: port python C wrapper to Python 3

Original patch provided by Mickael Maison.


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

Branch: refs/heads/master
Commit: efa1f6840225baf6902d7b0eff3d6c3e2f994bc2
Parents: 93ccc73
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Apr 22 15:13:01 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Apr 22 15:13:01 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/cproton.i          | 62 ++++++++++++++++--------
 proton-c/bindings/python/proton/__init__.py | 33 ++++++++++---
 proton-c/bindings/python/proton/handlers.py |  4 +-
 proton-c/bindings/python/proton/reactor.py  |  6 ++-
 proton-c/bindings/python/proton/utils.py    |  4 +-
 5 files changed, 77 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/efa1f684/proton-c/bindings/python/cproton.i
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/cproton.i b/proton-c/bindings/python/cproton.i
index 70d6c42..5744a2d 100644
--- a/proton-c/bindings/python/cproton.i
+++ b/proton-c/bindings/python/cproton.i
@@ -38,6 +38,27 @@
 %cstring_output_allocate_size(char **ALLOC_OUTPUT, size_t *ALLOC_SIZE, free(*$1));
 %cstring_output_maxsize(char *OUTPUT, size_t MAX_OUTPUT_SIZE)
 
+// Typemap for methods that return binary data:
+// force the return type as binary - this is necessary for Python3
+%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (char *BIN_OUT, size_t *BIN_SIZE)
+(int res, size_t n, char *buff = 0, $*2_ltype size) {
+  res = SWIG_AsVal(size_t)($input, &n);
+  if (!SWIG_IsOK(res)) {
+    %argument_fail(res, "(char *BIN_OUT, size_t *BIN_SIZE)", $symname, $argnum);
+  }
+  buff= %new_array(n+1, char);
+  $1 = %static_cast(buff, $1_ltype);
+  size = %numeric_cast(n,$*2_ltype);
+  $2 = &size;
+}
+%typemap(freearg,noblock=1,match="in")(char *BIN_OUT, size_t *BIN_SIZE) {
+  if (buff$argnum) %delete_array(buff$argnum);
+}
+%typemap(argout,noblock=1) (char *BIN_OUT, size_t *BIN_SIZE) {
+  %append_output(PyBytes_FromStringAndSize($1,*$2));
+}
+
+
 // These are not used/needed in the python binding
 %ignore pn_message_get_id;
 %ignore pn_message_set_id;
@@ -49,20 +70,21 @@
     $1.start = NULL;
     $1.size = 0;
   } else {
-    $1.start = PyString_AsString($input);
+    $1.start = PyBytes_AsString($input);
+
     if (!$1.start) {
       return NULL;
     }
-    $1.size = PyString_Size($input);
+    $1.size = PyBytes_Size($input);
   }
 }
 
 %typemap(out) pn_bytes_t {
-  $result = PyString_FromStringAndSize($1.start, $1.size);
+  $result = PyBytes_FromStringAndSize($1.start, $1.size);
 }
 
 %typemap(out) pn_delivery_tag_t {
-  $result = PyString_FromStringAndSize($1.bytes, $1.size);
+  $result = PyBytes_FromStringAndSize($1.bytes, $1.size);
 }
 
 %typemap(in) pn_uuid_t {
@@ -70,9 +92,9 @@
   if ($input == Py_None) {
     ; // Already zeroed out
   } else {
-    const char* b = PyString_AsString($input);
+    const char* b = PyBytes_AsString($input);
     if (b) {
-        memmove($1.bytes, b, (PyString_Size($input) < 16 ? PyString_Size($input) : 16));
+        memmove($1.bytes, b, (PyBytes_Size($input) < 16 ? PyBytes_Size($input) : 16));
     } else {
         return NULL;
     }
@@ -80,12 +102,12 @@
 }
 
 %typemap(out) pn_uuid_t {
-  $result = PyString_FromStringAndSize($1.bytes, 16);
+  $result = PyBytes_FromStringAndSize($1.bytes, 16);
 }
 
 %apply pn_uuid_t { pn_decimal128_t };
 
-int pn_message_encode(pn_message_t *msg, char *OUTPUT, size_t *OUTPUT_SIZE);
+int pn_message_encode(pn_message_t *msg, char *BIN_OUT, size_t *BIN_SIZE);
 %ignore pn_message_encode;
 
 ssize_t pn_link_send(pn_link_t *transport, char *STRING, size_t LENGTH);
@@ -93,12 +115,12 @@ ssize_t pn_link_send(pn_link_t *transport, char *STRING, size_t LENGTH);
 
 %rename(pn_link_recv) wrap_pn_link_recv;
 %inline %{
-  int wrap_pn_link_recv(pn_link_t *link, char *OUTPUT, size_t *OUTPUT_SIZE) {
-    ssize_t sz = pn_link_recv(link, OUTPUT, *OUTPUT_SIZE);
+  int wrap_pn_link_recv(pn_link_t *link, char *BIN_OUT, size_t *BIN_SIZE) {
+    ssize_t sz = pn_link_recv(link, BIN_OUT, *BIN_SIZE);
     if (sz >= 0) {
-      *OUTPUT_SIZE = sz;
+      *BIN_SIZE = sz;
     } else {
-      *OUTPUT_SIZE = 0;
+      *BIN_SIZE = 0;
     }
     return sz;
   }
@@ -110,12 +132,12 @@ ssize_t pn_transport_push(pn_transport_t *transport, char *STRING, size_t LENGTH
 
 %rename(pn_transport_peek) wrap_pn_transport_peek;
 %inline %{
-  int wrap_pn_transport_peek(pn_transport_t *transport, char *OUTPUT, size_t *OUTPUT_SIZE) {
-    ssize_t sz = pn_transport_peek(transport, OUTPUT, *OUTPUT_SIZE);
+  int wrap_pn_transport_peek(pn_transport_t *transport, char *BIN_OUT, size_t *BIN_SIZE) {
+    ssize_t sz = pn_transport_peek(transport, BIN_OUT, *BIN_SIZE);
     if (sz >= 0) {
-      *OUTPUT_SIZE = sz;
+      *BIN_SIZE = sz;
     } else {
-      *OUTPUT_SIZE = 0;
+      *BIN_SIZE = 0;
     }
     return sz;
   }
@@ -146,12 +168,12 @@ ssize_t pn_data_decode(pn_data_t *data, char *STRING, size_t LENGTH);
 
 %rename(pn_data_encode) wrap_pn_data_encode;
 %inline %{
-  int wrap_pn_data_encode(pn_data_t *data, char *OUTPUT, size_t *OUTPUT_SIZE) {
-    ssize_t sz = pn_data_encode(data, OUTPUT, *OUTPUT_SIZE);
+  int wrap_pn_data_encode(pn_data_t *data, char *BIN_OUT, size_t *BIN_SIZE) {
+    ssize_t sz = pn_data_encode(data, BIN_OUT, *BIN_SIZE);
     if (sz >= 0) {
-      *OUTPUT_SIZE = sz;
+      *BIN_SIZE = sz;
     } else {
-      *OUTPUT_SIZE = 0;
+      *BIN_SIZE = 0;
     }
     return sz;
   }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/efa1f684/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
index cf73a53..8871eda 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -34,7 +34,9 @@ from __future__ import absolute_import
 from cproton import *
 from .wrapper import Wrapper
 
+import six
 import weakref, socket, sys, threading
+
 try:
   import uuid
 
@@ -94,10 +96,22 @@ except ImportError:
   def generate_uuid():
     return uuid4()
 
+#
+# Hacks to provide Python2 <---> Python3 compatibility
+#
 try:
   bytes()
 except NameError:
   bytes = str
+try:
+  long()
+except NameError:
+  long = int
+try:
+  unicode()
+except NameError:
+  unicode = str
+
 
 VERSION_MAJOR = PN_VERSION_MAJOR
 VERSION_MINOR = PN_VERSION_MINOR
@@ -936,7 +950,7 @@ The number of delivery attempts made for this message.
   def _get_id(self):
     return self._id.get_object()
   def _set_id(self, value):
-    if type(value) in (int, long):
+    if type(value) in six.integer_types:
       value = ulong(value)
     self._id.rewind()
     self._id.put_object(value)
@@ -992,7 +1006,7 @@ The reply-to address for the message.
   def _get_correlation_id(self):
     return self._correlation_id.get_object()
   def _set_correlation_id(self, value):
-    if type(value) in (int, long):
+    if type(value) in six.integer_types:
       value = ulong(value)
     self._correlation_id.rewind()
     self._correlation_id.put_object(value)
@@ -1424,7 +1438,7 @@ class Data:
   def type_name(type): return Data.type_names[type]
 
   def __init__(self, capacity=16):
-    if type(capacity) in (int, long):
+    if type(capacity) in six.integer_types:
       self._data = pn_data(capacity)
       self._free = True
     else:
@@ -2146,7 +2160,6 @@ class Data:
     symbol: put_symbol,
     int: put_long,
     char: put_char,
-    long: put_long,
     ulong: put_ulong,
     timestamp: put_timestamp,
     float: put_double,
@@ -2154,6 +2167,10 @@ class Data:
     Described: put_py_described,
     Array: put_py_array
     }
+  # for python 2.x:
+  if long not in put_mappings:
+      put_mappings[long] = put_long
+
   get_mappings = {
     NULL: lambda s: None,
     BOOL: get_bool,
@@ -2319,7 +2336,7 @@ def millis2timeout(millis):
 def unicode2utf8(string):
     if string is None:
         return None
-    if isinstance(string, unicode):
+    if isinstance(string, six.text_type):
         return string.encode('utf8')
     elif isinstance(string, str):
         return string
@@ -2329,7 +2346,7 @@ def unicode2utf8(string):
 def utf82unicode(string):
     if string is None:
         return None
-    if isinstance(string, unicode):
+    if isinstance(string, six.text_type):
         return string
     elif isinstance(string, str):
         return string.decode('utf8')
@@ -3733,7 +3750,7 @@ class _cadapter:
 
   def exception(self, exc, val, tb):
     if self.on_error is None:
-      raise exc, val, tb
+      six.reraise(exc, val, tb)
     else:
       self.on_error((exc, val, tb))
 
@@ -3754,7 +3771,7 @@ class WrappedHandler(Wrapper):
   def _on_error(self, info):
     on_error = getattr(self, "on_error", None)
     if on_error is None:
-      raise info[0], info[1], info[2]
+      six.reraise(info[0], info[1], info[2])
     else:
       on_error(info)
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/efa1f684/proton-c/bindings/python/proton/handlers.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/handlers.py b/proton-c/bindings/python/proton/handlers.py
index 6836788..8f00aa3 100644
--- a/proton-c/bindings/python/proton/handlers.py
+++ b/proton-c/bindings/python/proton/handlers.py
@@ -16,7 +16,9 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-import heapq, logging, os, Queue, re, socket, time, types
+import heapq, logging, os, re, socket, time, types
+from six.moves import queue as Queue
+
 from proton import dispatch, generate_uuid, PN_ACCEPTED, SASL, symbol, ulong, Url
 from proton import Collector, Connection, Delivery, Described, Endpoint, Event, Link, Terminus, Timeout
 from proton import Message, Handler, ProtonException, Transport, TransportException, ConnectionException

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/efa1f684/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index 03d8af3..a9bd3cc 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -17,7 +17,9 @@ from __future__ import absolute_import
 # specific language governing permissions and limitations
 # under the License.
 #
-import logging, os, Queue, socket, time, types
+import logging, os, socket, time, types
+import six
+from six.moves import queue as Queue
 from heapq import heappush, heappop, nsmallest
 from proton import Collector, Connection, ConnectionException, Delivery, Described, dispatch
 from proton import Endpoint, Event, EventBase, EventType, generate_uuid, Handler, Link, Message
@@ -137,7 +139,7 @@ class Reactor(Wrapper):
             for exc, value, tb in self.errors[:-1]:
                 traceback.print_exception(exc, value, tb)
             exc, value, tb = self.errors[-1]
-            raise exc, value, tb
+            six.reraise(exc, value, tb)
 
     def process(self):
         result = pn_reactor_process(self._impl)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/efa1f684/proton-c/bindings/python/proton/utils.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/utils.py b/proton-c/bindings/python/proton/utils.py
index cb65fda..0d7f39e 100644
--- a/proton-c/bindings/python/proton/utils.py
+++ b/proton-c/bindings/python/proton/utils.py
@@ -16,7 +16,9 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-import collections, Queue, socket, time, threading
+import collections, socket, time, threading
+from six.moves import queue as Queue
+
 from proton import ConnectionException, Delivery, Endpoint, Handler, LinkException, Message
 from proton import ProtonException, Timeout, Url
 from proton.reactor import Container


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[07/34] qpid-proton git commit: PROTON-490: port mllib document parser to Python 3

Posted by kg...@apache.org.
PROTON-490: port mllib document parser to Python 3


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

Branch: refs/heads/master
Commit: e87a6d313ecf2f468852de83126b1fdd7924b737
Parents: 903c724 5d7a458
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Apr 22 10:55:12 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Apr 22 10:55:12 2015 -0400

----------------------------------------------------------------------
 proton-c/mllib/__init__.py   | 27 ++++++++-------------------
 proton-c/mllib/dom.py        |  7 ++++---
 proton-c/mllib/parsers.py    | 37 ++-----------------------------------
 proton-c/mllib/transforms.py |  2 +-
 4 files changed, 15 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e87a6d31/proton-c/mllib/__init__.py
----------------------------------------------------------------------
diff --cc proton-c/mllib/__init__.py
index c6fccf1,9e78a87..e506060
--- a/proton-c/mllib/__init__.py
+++ b/proton-c/mllib/__init__.py
@@@ -28,10 -27,11 +27,15 @@@ import os, sy
  import xml.sax, types
  from xml.sax.handler import ErrorHandler
  from xml.sax.xmlreader import InputSource
- from cStringIO import StringIO
+ import six
+ from six.moves import cStringIO as StringIO
+ 
+ from . import dom
+ from . import transforms
++from . import parsers
 +
 +from . import dom
 +from . import transforms
  from . import parsers
  
  def transform(node, *args):


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[34/34] qpid-proton git commit: PROTON-490: Merge branch 'kgiusti-python3'

Posted by kg...@apache.org.
PROTON-490: Merge branch 'kgiusti-python3'


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

Branch: refs/heads/master
Commit: 17594bc3fbb3ff863e9b8d1349b3cdeb90d1a9f6
Parents: 653f4e5 e7f49fa
Author: Ken Giusti <kg...@apache.org>
Authored: Mon Jun 22 08:50:24 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Jun 22 08:50:24 2015 -0400

----------------------------------------------------------------------
 examples/python/abstract_server.py             |   3 +-
 examples/python/client.py                      |   3 +-
 examples/python/client_http.py                 |   3 +-
 examples/python/db_common.py                   |   6 +-
 examples/python/db_ctrl.py                     |   7 +-
 examples/python/db_recv.py                     |   3 +-
 examples/python/db_send.py                     |  18 ++-
 examples/python/direct_recv.py                 |   3 +-
 examples/python/direct_send.py                 |   3 +-
 examples/python/helloworld.py                  |   5 +-
 examples/python/helloworld_blocking.py         |   5 +-
 examples/python/helloworld_direct.py           |   5 +-
 examples/python/helloworld_direct_tornado.py   |   5 +-
 examples/python/helloworld_tornado.py          |   5 +-
 examples/python/messenger/async.py             |   5 +-
 examples/python/messenger/client.py            |   7 +-
 examples/python/messenger/recv.py              |   7 +-
 examples/python/messenger/recv_async.py        |  11 +-
 examples/python/messenger/send.py              |   5 +-
 examples/python/messenger/send_async.py        |   9 +-
 examples/python/messenger/server.py            |   5 +-
 examples/python/proton_server.py               |   3 +-
 examples/python/queue_browser.py               |   3 +-
 examples/python/reactor/cat.py                 |   3 +-
 examples/python/reactor/count-randomly.py      |   9 +-
 examples/python/reactor/counter.py             |   7 +-
 examples/python/reactor/delegates.py           |   5 +-
 examples/python/reactor/echo.py                |   5 +-
 examples/python/reactor/global-logger.py       |   9 +-
 examples/python/reactor/goodbye-world.py       |   5 +-
 examples/python/reactor/handlers.py            |   7 +-
 examples/python/reactor/hello-world.py         |   3 +-
 examples/python/reactor/reactor-logger.py      |   7 +-
 examples/python/reactor/recv.py                |   3 +-
 examples/python/reactor/scheduling.py          |   7 +-
 examples/python/reactor/tornado-hello-world.py |   3 +-
 examples/python/reactor/unhandled.py           |   3 +-
 examples/python/recurring_timer.py             |   5 +-
 examples/python/recurring_timer_tornado.py     |   5 +-
 examples/python/selected_recv.py               |   5 +-
 examples/python/server.py                      |   5 +-
 examples/python/server_direct.py               |   7 +-
 examples/python/server_tx.py                   |   5 +-
 examples/python/simple_recv.py                 |   3 +-
 examples/python/simple_send.py                 |   3 +-
 examples/python/sync_client.py                 |   3 +-
 examples/python/test_examples.py               |  55 ++++---
 examples/python/tx_recv.py                     |   3 +-
 examples/python/tx_recv_interactive.py         |  11 +-
 examples/python/tx_send.py                     |   3 +-
 proton-c/CMakeLists.txt                        |   5 +-
 proton-c/bindings/python/cproton.i             | 114 +++++++++++----
 proton-c/bindings/python/proton/__init__.py    | 117 +++++++++------
 proton-c/bindings/python/proton/_compat.py     |  84 +++++++++++
 proton-c/bindings/python/proton/handlers.py    |   3 +-
 proton-c/bindings/python/proton/reactor.py     |  27 ++--
 proton-c/bindings/python/proton/utils.py       |  14 +-
 proton-c/bindings/python/proton/wrapper.py     |  12 +-
 proton-c/bindings/python/setup.py              |  29 +++-
 proton-c/bindings/python/tox.ini               |  23 +--
 proton-c/mllib/__init__.py                     |  40 ++---
 proton-c/mllib/dom.py                          |  16 +-
 proton-c/mllib/parsers.py                      |  40 +----
 proton-c/mllib/transforms.py                   |   8 +-
 proton-c/src/codec/encodings.h.py              |  17 ++-
 proton-c/src/protocol.h.py                     |  91 ++++++------
 proton-j/src/main/resources/cmessage.py        |   2 +-
 tests/python/proton-test                       |  32 ++--
 tests/python/proton_tests/codec.py             |  32 ++--
 tests/python/proton_tests/common.py            |  35 ++++-
 tests/python/proton_tests/engine.py            | 153 +++++++++++---------
 tests/python/proton_tests/interop.py           |   8 +-
 tests/python/proton_tests/message.py           |   9 +-
 tests/python/proton_tests/messenger.py         |  15 +-
 tests/python/proton_tests/reactor.py           |   3 +-
 tests/python/proton_tests/sasl.py              |  19 +--
 tests/python/proton_tests/soak.py              |   3 +-
 tests/python/proton_tests/ssl.py               |  11 +-
 tests/python/proton_tests/transport.py         |  66 +++++----
 tests/python/proton_tests/url.py               |   3 +-
 tests/python/proton_tests/utils.py             |   2 +-
 tests/smoke/recv.py                            |   3 +-
 tests/smoke/send.py                            |   5 +-
 tests/tools/apps/python/msgr-recv.py           |   6 +
 tests/tools/apps/python/msgr-send.py           |   6 +
 tests/tools/soak-check                         |   5 +-
 86 files changed, 858 insertions(+), 518 deletions(-)
----------------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[19/34] qpid-proton git commit: PROTON-490: have tests ignore platform-specific line endings

Posted by kg...@apache.org.
PROTON-490: have tests ignore platform-specific line endings


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

Branch: refs/heads/master
Commit: 45238b464507871e732ceb363f8fb23b0abdf8df
Parents: 758295d
Author: Ken Giusti <kg...@apache.org>
Authored: Fri May 1 12:55:38 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Fri May 1 12:55:38 2015 -0400

----------------------------------------------------------------------
 tests/python/proton_tests/common.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45238b46/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py b/tests/python/proton_tests/common.py
index be9c75a..4f23c13 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -418,7 +418,7 @@ class MessengerReceiver(MessengerApp):
     def _ready(self):
         """ wait for subscriptions to complete setup. """
         r = self._process.stdout.readline()
-        assert r == "READY" + os.linesep, "Unexpected input while waiting for receiver to initialize: %s" % r
+        assert r.strip() == "READY", "Unexpected input while waiting for receiver to initialize: %s" % r
 
 class MessengerSenderC(MessengerSender):
     def __init__(self):


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[33/34] qpid-proton git commit: PROTON-490: fail ctest if any of the tox runs fail

Posted by kg...@apache.org.
PROTON-490: fail ctest if any of the tox runs fail


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

Branch: refs/heads/master
Commit: e7f49fa0ac9083d8efab697c47c46a91c458187d
Parents: 35eb6bb
Author: Ken Giusti <kg...@apache.org>
Authored: Thu Jun 18 16:09:31 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Thu Jun 18 16:09:31 2015 -0400

----------------------------------------------------------------------
 proton-c/CMakeLists.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e7f49fa0/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index 5985e2d..a1cf0e4 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -523,7 +523,10 @@ if (BUILD_PYTHON)
 		   "PATH=${py_path}" "QPID_PROTON_SRC=${CMAKE_CURRENT_SOURCE_DIR}/../" ${VALGRIND_ENV}
                    tox
 		   WORKING_DIRECTORY ${py_src})
-         set_tests_properties(python-tox-test PROPERTIES PASS_REGULAR_EXPRESSION "Totals: .* 0 failed")
+         set_tests_properties(python-tox-test
+                              PROPERTIES
+                              PASS_REGULAR_EXPRESSION "Totals: .* ignored, 0 failed"
+                              FAIL_REGULAR_EXPRESSION "ERROR:[ ]+py[0-9]*: commands failed")
      else (TOX_CMD)
          message(STATUS "The tox tool is not available - skipping the python-tox-tests")
      endif (TOX_CMD)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[30/34] qpid-proton git commit: PROTON-490: Check on linux|linux2 in the setup.py

Posted by kg...@apache.org.
PROTON-490: Check on linux|linux2 in the setup.py

(cherry picked from commit cf3acf7cf9b7a06dbbcc5afee4ec6df2ec66e488)


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

Branch: refs/heads/master
Commit: 13546483d2e1cdc26a2d941763db078a07e54d0d
Parents: 13cc729
Author: Flavio Percoco <fl...@gmail.com>
Authored: Thu Jun 18 11:34:51 2015 +0200
Committer: Ken Giusti <kg...@apache.org>
Committed: Thu Jun 18 14:00:47 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/setup.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/13546483/proton-c/bindings/python/setup.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setup.py b/proton-c/bindings/python/setup.py
index 1620b38..4cdd721 100755
--- a/proton-c/bindings/python/setup.py
+++ b/proton-c/bindings/python/setup.py
@@ -335,7 +335,8 @@ class Configure(build_ext):
         return not self.check_qpid_proton_version()
 
     def run(self):
-        if sys.platform == 'linux2':
+        # linux2 for python<3.0
+        if sys.platform in ['linux', 'linux2']:
             if self.bundle_proton:
                 self.bundle_libqpid_proton_extension()
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org