You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by GitBox <gi...@apache.org> on 2020/06/17 18:27:00 UTC

[GitHub] [qpid-proton] astitcher commented on a change in pull request #256: PROTON-2237: Correct checking of Proton message property keys

astitcher commented on a change in pull request #256:
URL: https://github.com/apache/qpid-proton/pull/256#discussion_r436066742



##########
File path: python/proton/_message.py
##########
@@ -90,10 +90,12 @@ def _check(self, err):
 
     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

Review comment:
       I really don't understand why this is better than 
   ```if isinstance(k, unicode) and not type(k) is symbol:```

##########
File path: python/proton/_message.py
##########
@@ -90,13 +90,16 @@ def _check(self, err):
 
     def _check_property_keys(self):
         for k in self.properties.keys():
-            if isinstance(k, unicode):
-                # py2 unicode, py3 str (via hack definition)
+            # 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:

Review comment:
       I think do the opposite - check for the specific single type symbol and error out for it - every other string type is allowed. @ssorj what do you think?

##########
File path: python/proton/_message.py
##########
@@ -90,10 +90,12 @@ def _check(self, err):
 
     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:

Review comment:
       Note that ```==``` is not the correct test here ```is``` would be the correct test.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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