Uploaded image for project: 'Qpid Proton'
  1. Qpid Proton
  2. PROTON-1835

[python] Use of Python dict for AMQP maps does not allow derived or related keys of the same value

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • python-binding
    • None

    Description

      The AMQP map (expressed as a list) [binary(123), "hello", decimal128(123), "world"] cannot be implemented in Python using the dict type. This happens because proton.decimal is derived from bytes, and the dictionary treats the keys as the same value and causes the first value to be overwritten by the second:

      >>> import proton
      >>> {b'123': 'hello', proton.decimal128(b'123'): 'world'}
      {'123': 'world'}
      

      Using the [] operator to add the values one at a time to an empty dict results in the same outcome. Even using related classes (ie both derived from a common parent) don't work:

      >>> import proton
      >>> class mybin(bytes):
      ...     def __repr__(self):
      ...         return 'mybin(%s)' % bytes.__repr__(self)
      ... 
      >>> {mybin(b'123'): 'hello', proton.decimal128(b'123'): 'world'}
      {mybin('123'): 'world'}
      

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            kpvdr Kim van der Riet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: