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

[python] TypeError on listener when handling address already in use

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • proton-c-0.18.0
    • proton-c-0.18.0
    • python-binding
    • None
    • Patch

    Description

      There is a wrong syntax in exception handling code when raising the "Address already in use" error in proton-c/bindings/python/proton/reactor.py (line 179):

      raise IOError("%s (%s:%s)" % pn_error_text(pn_reactor_error(self._impl)), host, port)
      

      Which leads to unexpected TypeError:

      Traceback (most recent call last):
        File "in_handler.py", line 15, in <module>
          container.run()
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 133, in run
          while self.process(): pass
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 159, in process
          self._check_errors()
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 155, in _check_errors
          _compat.raise_(exc, value, tb)
        File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 4040, in dispatch
          ev.dispatch(self.handler)
        File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 3949, in dispatch
          result = dispatch(handler, type.method, self)
        File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 3827, in dispatch
          return m(*args)
        File "/usr/lib64/python2.7/site-packages/proton/handlers.py", line 436, in on_reactor_init
          self.on_start(event)
        File "in_handler.py", line 6, in on_start
          acceptor = event.container.listen("localhost:5672")
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 869, in listen
          acceptor = self.acceptor(url.host, url.port)
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 179, in acceptor
          raise IOError("%s (%s:%s)" % pn_error_text(pn_reactor_error(self._impl)), host, port)
      TypeError: not enough arguments for format string
      

      Proposed fix:

      diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
      index 269ed9e..a0699c8 100644
      --- a/proton-c/bindings/python/proton/reactor.py
      +++ b/proton-c/bindings/python/proton/reactor.py
      @@ -176,7 +176,7 @@ class Reactor(Wrapper):
               if aimpl:
                   return Acceptor(aimpl)
               else:
      -            raise IOError("%s (%s:%s)" % pn_error_text(pn_reactor_error(self._impl)), host, port)
      +            raise IOError("%s (%s:%s)" % (pn_error_text(pn_reactor_error(self._impl)), host, port))
       
           def connection(self, handler=None):
               """Deprecated: use connection_to_host() instead
      

      Attachments

        Issue Links

          Activity

            People

              astitcher Andrew Stitcher
              jdanek Jiri Daněk
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: