You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2016/10/14 18:52:48 UTC
qpid-proton git commit: PROTON-1325: Python "buffer" type should map
to AMQP "binary"
Repository: qpid-proton
Updated Branches:
refs/heads/master 3dd69944f -> 05deba72e
PROTON-1325: Python "buffer" type should map to AMQP "binary"
Add an automatic mapping from a python buffer object to the AMQP binary type.
In the other direction, AMQP "binary" maps to the python "bytes" or "str" type, as before.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/05deba72
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/05deba72
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/05deba72
Branch: refs/heads/master
Commit: 05deba72edebd0cf1e7bf148ba7e99ab2fb62bfe
Parents: 3dd6994
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Oct 14 14:24:06 2016 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Oct 14 14:37:17 2016 -0400
----------------------------------------------------------------------
proton-c/bindings/python/proton/__init__.py | 3 ++-
tests/python/proton_tests/codec.py | 9 +++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05deba72/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 25afa44..1478d38 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -1840,7 +1840,7 @@ class Data:
@type b: binary
@param b: a binary value
"""
- self._check(pn_data_put_binary(self._data, b))
+ self._check(pn_data_put_binary(self._data, bytes(b)))
def put_string(self, s):
"""
@@ -2229,6 +2229,7 @@ class Data:
list: put_sequence,
tuple: put_sequence,
dict: put_dict,
+ buffer: put_binary,
Described: put_py_described,
Array: put_py_array
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05deba72/tests/python/proton_tests/codec.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/codec.py b/tests/python/proton_tests/codec.py
index 9f246bf..b7bb04d 100644
--- a/tests/python/proton_tests/codec.py
+++ b/tests/python/proton_tests/codec.py
@@ -357,6 +357,15 @@ class DataTest(Test):
copy = data.get_object()
assert copy == obj, (copy, obj)
+ def testBuffer(self):
+ self.data.put_object(buffer("foo"))
+ data = Data()
+ data.decode(self.data.encode())
+ data.rewind()
+ assert data.next()
+ assert data.type() == Data.BINARY
+ assert data.get_object() == "foo"
+
def testLookup(self):
obj = {symbol("key"): str2unicode("value"),
symbol("pi"): 3.14159,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org