qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kp...@apache.org
Subject [qpid-proton] branch python-check-property-keys updated: PROTON-2237: Alternative approach which converts all child classes of string/unicode to the base class, including proton symbol and char types.
Date Thu, 04 Jun 2020 17:37:22 GMT
This is an automated email from the ASF dual-hosted git repository.

kpvdr pushed a commit to branch python-check-property-keys
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


The following commit(s) were added to refs/heads/python-check-property-keys by this push:
     new 6586996  PROTON-2237: Alternative approach which converts all child classes of string/unicode
to the base class, including proton symbol and char types.
6586996 is described below

commit 65869963ea8b35927e6a0890052c08ca587da022
Author: Kim van der Riet <kpvdr@apache.org>
AuthorDate: Thu Jun 4 13:36:53 2020 -0400

    PROTON-2237: Alternative approach which converts all child classes of string/unicode to
the base class, including proton symbol and char types.
---
 python/proton/_message.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/python/proton/_message.py b/python/proton/_message.py
index 5ed94ae..8d733f0 100644
--- a/python/proton/_message.py
+++ b/python/proton/_message.py
@@ -34,7 +34,7 @@ from cproton import PN_DEFAULT_PRIORITY, PN_OVERFLOW, pn_error_text, pn_message,
 
 from . import _compat
 from ._common import isinteger, millis2secs, secs2millis, unicode2utf8, utf82unicode
-from ._data import Data, symbol, ulong, AnnotationDict
+from ._data import char, Data, symbol, ulong, AnnotationDict
 from ._endpoints import Link
 from ._exceptions import EXCEPTIONS, MessageException
 
@@ -90,10 +90,12 @@ class Message(object):
 
     def _check_property_keys(self):
         for k in self.properties.keys():
-            # Check for string type. (py2: unicode, py3: str via type hack above)
-            # String subclasses symbol and char are excluded
-            # (But so are other string subclasses that would be encoded as type string!)
-            if type(k) == unicode:
+            # Check for string types. (py2: unicode, py3: str via type hack above)
+            # or string subclasses
+            if isinstance(k, unicode):
+                # Convert string subclasses (including proton char and symbol types) to string
+                if not type(k) == unicode:
+                    self.properties[unicode(k)] = self.properties.pop(k)
                 continue
             # If key is binary then change to string
             # Mostly for py2 users who encode strings without using the u'' prefix


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


Mime
View raw message