[
https://issues.apache.org/jira/browse/PROTON-308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13652964#comment-13652964
]
Rafael H. Schloming commented on PROTON-308:
The behaviour is intentional although admittedly it can lead to some gotchas.
The reason for the behaviour is that in python the str type is used in two
ways. It's used for both arbitrary binary data, and for representing ascii
strings. This presents a problem when trying to map it into the AMQP type
system because an AMQP string is only capable of containing valid unicode and
we have no way of knowing whether a given str object is being used to represent
binary data or unicode data. For this reason we don't have much choice but to
map the str type into the amqp binary type and make people explicitly use the
unicode type if they want an AMQP string.
FWIW, the real source of the unintuitiveness here is python's ambiguous use of
the str type. This has been addressed in later versions. At some point in the
2.x series they introduced bytes as an alias for str, and in Python 3 they've
transitioned to completely separate str and bytes types
(http://eli.thegreenplace.net/2012/01/30/the-bytesstr-dichotomy-in-python-3/).
I'm open to any suggestions on how to improve things and eliminate the gotcha,
but I can't think of too many options other than documenting it well.
> Python Messenger: Strings encoded in map bodies are encoded as binary, not
> string
> -
>
> Key: PROTON-308
> URL: https://issues.apache.org/jira/browse/PROTON-308
> Project: Qpid Proton
> Issue Type: Bug
> Components: proton-c
>Affects Versions: 0.4
>Reporter: Ted Ross
> Fix For: 0.5
>
>
> I'm using the following code to create a message in Python Messenger:
> from proton import Messenger, Message
> mng = Messenger()
> msg = Message()
> mng.start()
> msg.address = "amqp://0.0.0.0/_local/agent"
> msg.body = {'opcode':'test'}
> mng.put(msg)
> mng.send()
> mng.stop()
> The message body is encoded as an AMQP Value and the value is a map32. The
> key value in the map is encoded as a vbin8. It should be a str8_utf8.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira