You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kp...@apache.org on 2018/02/02 21:53:48 UTC
qpid-proton git commit: PROTON-1758: Change message application
properties that are binary to unicode string; raise error for other key types.
Repository: qpid-proton
Updated Branches:
refs/heads/master c6bfeff2a -> ae3eaaa2e
PROTON-1758: Change message application properties that are binary to unicode string; raise error for other key types.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ae3eaaa2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ae3eaaa2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ae3eaaa2
Branch: refs/heads/master
Commit: ae3eaaa2e2351b29c23825d141ac9b5ba17cbdf6
Parents: c6bfeff
Author: Kim van der Riet <kv...@localhost.localdomain>
Authored: Fri Feb 2 16:53:33 2018 -0500
Committer: Kim van der Riet <kv...@localhost.localdomain>
Committed: Fri Feb 2 16:53:33 2018 -0500
----------------------------------------------------------------------
proton-c/bindings/python/proton/__init__.py | 8 ++++++++
proton-c/bindings/python/proton/_compat.py | 6 ++++++
2 files changed, 14 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ae3eaaa2/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 5c4dea7..1878d57 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -841,6 +841,13 @@ class Message(object):
else:
return err
+ def _check_property_keys(self):
+ for k in self.properties.keys():
+ if not isinstance(k, (bytes, str, unicode)):
+ raise MessageException('Application property key is not unicode string: key=%s %s' % (str(k), type(k)))
+ if isinstance(k, bytes):
+ self.properties[_compat.bin2str(k)] = self.properties.pop(k)
+
def _pre_encode(self):
inst = Data(pn_message_instructions(self._msg))
ann = Data(pn_message_annotations(self._msg))
@@ -855,6 +862,7 @@ class Message(object):
ann.put_object(self.annotations)
props.clear()
if self.properties is not None:
+ self._check_property_keys()
props.put_object(self.properties)
body.clear()
if self.body is not None:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ae3eaaa2/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
index 4585dfc..c8815f4 100644
--- a/proton-c/bindings/python/proton/_compat.py
+++ b/proton-c/bindings/python/proton/_compat.py
@@ -44,6 +44,9 @@ if IS_PY3:
else:
raise v.with_traceback(tb)
+ def bin2str(s, encoding='utf-8'):
+ return s
+
def iteritems(d):
return iter(d.items())
@@ -71,6 +74,9 @@ else:
raise t, v, tb
""")
+ def bin2str(s, encoding='utf-8'):
+ return s.decode(encoding)
+
def iteritems(d, **kw):
return d.iteritems()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org