You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by gi...@git.apache.org on 2017/10/04 22:08:47 UTC
[GitHub] merlimat commented on issue #812: Add method to returns bytes type in Python client
merlimat commented on issue #812: Add method to returns bytes type in Python client
URL: https://github.com/apache/incubator-pulsar/pull/812#issuecomment-334303925
> If we can break compatibility with the existing version, I think we should make data in Message class return bytes type like getMessage of Java Client.
I think that as well.. Using `message.data()` to return bytes seems a better option:
* In Python 2.7, there should be no difference between `bytes` and `string` as I understand
* In Python 3.x, it's actually very tricky to return a proper string from the API, since we don't know the eventual string encoding, if it is a string a all.
* By always returning `bytes` we force the user to deal and reason about the encoding, and it will be the same as in C++ and Java (C++ string can actually hold whatever content).
@kyontan Thanks for finding this out and the change looks good, can you also update the `pulsar.py` wrapper documentation to specify that the return type will be `bytes`? https://github.com/apache/incubator-pulsar/blob/df5be460bf1bf4f04c5572452aafd879cd1213f6/pulsar-client-cpp/python/pulsar.py#L140
----------------------------------------------------------------
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