[ 
https://issues.apache.org/jira/browse/PROTON-995?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15013725#comment-15013725
 ] 

Alan Conway commented on PROTON-995:
------------------------------------

Sorry, I mis-understood, you are 100% correct. The problem is in the python Url 
class. The underlying C URL parser decodes the escapes correctly but the python 
Url class does not re-encode them so the round-trip Url(str(Url('something with 
escapes')) causes madness. I can fix this for the next release and will post 
the patch here if that helps, otherwise in the short term try this workaround:

c = Container()
conn = 
Container.connection('amqps://a_name:1w6MN0yeUqLUwDdWHk%2FxIR2Z6aIrhslm69lYtHA0r5E%3D@a_namespace.servicebus.windows.net')
r = c.create_receiver(conn, source='a_topic/Subscriptions/a_subscription')

This should avoids the python URL class by sending the connection details 
straight to C. It means you have to keep track of the connection rather than 
letting the container do it for ou  (which personally I prefer) and you need to 
split out the path part of the URL yourself and pass as the source= arg to 
create_receiver. Use create_sender(conn, target=xxx) for a sender

> Url fails to parse URL
> ----------------------
>
>                 Key: PROTON-995
>                 URL: https://issues.apache.org/jira/browse/PROTON-995
>             Project: Qpid Proton
>          Issue Type: Bug
>          Components: python-binding
>    Affects Versions: 0.10
>         Environment: Linux, Python 3.4.3
>            Reporter: Javier Ruere
>            Assignee: Alan Conway
>
> proton.Url apparently parses an URL correctly but then it fails as if it was 
> parsed incorrectly.
> It appears to fail to handle the escaped characters in the password and using 
> a default port.
> {quote}
> >>> import proton
> >>> from proton.reactor import Container
> >>> url = 
> >>> 'amqps://a_name:1w6MN0yeUqLUwDdWHk%2FxIR2Z6aIrhslm69lYtHA0r5E%3D@a_namespace.servicebus.windows.net/a_topic/Subscriptions/a_subscription'
> >>> purl=proton.Url(url)
> >>> purl
> Url('amqps://a_name:1w6MN0yeUqLUwDdWHk/xIR2Z6aIrhslm69lYtHA0r5E=@a_namespace.servicebus.windows.net:amqps/a_topic/Subscriptions/a_subscription')
> >>> container = Container()
> >>> receiver = container.create_receiver(purl)
> Traceback (most recent call last):
>   File 
> "/home/javier/tmp/virtualenvs/ss-update/lib/python3.4/site-packages/proton/__init__.py",
>  line 3940, in _port_int
>     return int(value)
> ValueError: invalid literal for int() with base 10: '1w6MN0yeUqLUwDdWHk'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
>   File 
> "/home/javier/tmp/virtualenvs/ss-update/lib/python3.4/site-packages/proton/__init__.py",
>  line 3943, in _port_int
>     return socket.getservbyname(value)
> OSError: service/proto not found
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File 
> "/home/javier/tmp/virtualenvs/ss-update/lib/python3.4/site-packages/proton/reactor.py",
>  line 738, in create_receiver
>     session = self._get_session(context)
>   File 
> "/home/javier/tmp/virtualenvs/ss-update/lib/python3.4/site-packages/proton/reactor.py",
>  line 660, in _get_session
>     return self._get_session(self.connect(url=context))
>   File 
> "/home/javier/tmp/virtualenvs/ss-update/lib/python3.4/site-packages/proton/reactor.py",
>  line 637, in connect
>     if url: connector.address = Urls([url])
>   File 
> "/home/javier/tmp/virtualenvs/ss-update/lib/python3.4/site-packages/proton/reactor.py",
>  line 577, in __init__
>     self.values = [Url(v) for v in values]
>   File 
> "/home/javier/tmp/virtualenvs/ss-update/lib/python3.4/site-packages/proton/reactor.py",
>  line 577, in <listcomp>
>     self.values = [Url(v) for v in values]
>   File 
> "/home/javier/tmp/virtualenvs/ss-update/lib/python3.4/site-packages/proton/__init__.py",
>  line 3967, in __init__
>     if defaults: self.defaults()
>   File 
> "/home/javier/tmp/virtualenvs/ss-update/lib/python3.4/site-packages/proton/__init__.py",
>  line 4010, in defaults
>     self.port = self.port or self.Port(self.scheme)
>   File 
> "/home/javier/tmp/virtualenvs/ss-update/lib/python3.4/site-packages/proton/__init__.py",
>  line 3984, in _get_port
>     return portstr and Url.Port(portstr)
>   File 
> "/home/javier/tmp/virtualenvs/ss-update/lib/python3.4/site-packages/proton/__init__.py",
>  line 3928, in __new__
>     port = super(Url.Port, cls).__new__(cls, cls._port_int(value))
>   File 
> "/home/javier/tmp/virtualenvs/ss-update/lib/python3.4/site-packages/proton/__init__.py",
>  line 3949, in _port_int
>     raise ValueError("Not a valid port number or service name: '%s'" % value)
> ValueError: Not a valid port number or service name: '1w6MN0yeUqLUwDdWHk'
> >>> 
> >>> purl.port
> 5671
> >>> purl.password
> '1w6MN0yeUqLUwDdWHk/xIR2Z6aIrhslm69lYtHA0r5E='
> >>> purl.host
> 'a_namespace.servicebus.windows.net'
> {quote}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to