Uploaded image for project: 'AMQ Clients'
  1. AMQ Clients
  2. ENTMQCL-498

[python] Unsigned types can hold negative values

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • 2.4.0.B1
    • 1.0.0-GA, 1.1.0-beta-2
    • amqp-python-client
    • None
    • Pacheco

    Description

      Python representations of:

      • proton.ubyte
      • proton.ushort
      • proton.uint
      • proton.ulong

      can hold a negative value, even though they should be unsigned

      import proton
      print proton.ubyte(-1)
      print proton.ushort(-1)
      print proton.uint(-1)
      print proton.ulong(-1)
      

      results in

      -1
      -1
      -1
      -1
      

      I would expect for unsigned type when negative value is supplied either TypeError or positive supplement, but latter will cause ambiguity.

      with real example trying to send such negative unsigned value, proton produces internal error

      SENDER: Created sender for target address '127.0.0.1:5672/example'
      Traceback (most recent call last):
        File "example_sender.py", line 45, in <module>
          container.run()
        File "/usr/lib64/python2.6/site-packages/proton/reactor.py", line 133, in run
          while self.process(): pass
        File "/usr/lib64/python2.6/site-packages/proton/reactor.py", line 159, in process
          self._check_errors()
        File "/usr/lib64/python2.6/site-packages/proton/reactor.py", line 155, in _check_errors
          _compat.raise_(exc, value, tb)
        File "/usr/lib64/python2.6/site-packages/proton/__init__.py", line 4050, in dispatch
          ev.dispatch(self.handler)
        File "/usr/lib64/python2.6/site-packages/proton/__init__.py", line 3962, in dispatch
          self.dispatch(h, type)
        File "/usr/lib64/python2.6/site-packages/proton/__init__.py", line 3959, in dispatch
          result = dispatch(handler, type.method, self)
        File "/usr/lib64/python2.6/site-packages/proton/__init__.py", line 3837, in dispatch
          return m(*args)
        File "/usr/lib64/python2.6/site-packages/proton/handlers.py", line 40, in on_link_flow
          self.on_sendable(event)
        File "/usr/lib64/python2.6/site-packages/proton/handlers.py", line 62, in on_sendable
          dispatch(self.delegate, 'on_sendable', event)
        File "/usr/lib64/python2.6/site-packages/proton/__init__.py", line 3837, in dispatch
          return m(*args)
        File "example_sender.py", line 28, in on_sendable
          event.sender.send(message)
        File "/usr/lib64/python2.6/site-packages/proton/__init__.py", line 3022, in send
          return obj.send(self, tag=tag)
        File "/usr/lib64/python2.6/site-packages/proton/__init__.py", line 1116, in send
          encoded = self.encode()
        File "/usr/lib64/python2.6/site-packages/proton/__init__.py", line 1099, in encode
          self._pre_encode()
        File "/usr/lib64/python2.6/site-packages/proton/__init__.py", line 843, in _pre_encode
          body.put_object(self.body)
        File "/usr/lib64/python2.6/site-packages/proton/__init__.py", line 2283, in put_object
          putter(self, obj)
        File "/usr/lib64/python2.6/site-packages/proton/__init__.py", line 1714, in put_ubyte
          self._check(pn_data_put_ubyte(self._data, ub))
      OverflowError: in method 'pn_data_put_ubyte', argument 2 of type 'uint8_t'
      

      Attachments

        Activity

          People

            kvanderr@redhat.com Kim van der Riet
            zkraus@redhat.com Zdenek Kraus
            Radim Kubis Radim Kubis
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: