You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/05/02 04:11:32 UTC

[GitHub] szha commented on a change in pull request #10697: [MXNET-360]auto convert str to bytes in img.imdecode when py3

szha commented on a change in pull request #10697: [MXNET-360]auto convert str to bytes in img.imdecode when py3
URL: https://github.com/apache/incubator-mxnet/pull/10697#discussion_r185389574
 
 

 ##########
 File path: python/mxnet/image/image.py
 ##########
 @@ -132,6 +134,9 @@ def imdecode(buf, *args, **kwargs):
     <NDArray 224x224x3 @cpu(0)>
     """
     if not isinstance(buf, nd.NDArray):
+        if sys.version_info[0] == 3:
+            if isinstance(buf, str):
+                buf = bytes(buf, "ascii")
 
 Review comment:
   This case really shouldn't happen, because in this case the API is underspecified.
   
   String is always tied to an encoding, and if the string comes from the user, it could have been decoded with any encoding/charset, so the 'ascii' assumption can easily be wrong.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services