Il giorno 22 giugno 2016 12:43, Marco De Paoli <depao...@gmail.com> ha scritto:
> pare che urlparse nella lib standard abbia un comportamento un po' > strano... > > Python 2.7.6 (default, Jun 22 2015, 17:58:13) > [GCC 4.8.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> from urlparse import urlparse > >>> u = urlparse('redis://localhost:6380') > >>> u.port > 6380 > >>> u = urlparse('redis://localhost:63801') > >>> u.port > 63801 > >>> u = urlparse('redis://localhost:638012') > >>> u.port > >>> u.port is None > True > > stessa cosa succede su python 3 > cambiando ovviamente l'import > >>> from urllib.parse import urlparse > > > Daccordo che il port number è un intero a 16-bit, per cui oltre 65535 non > ha senso, però forse mi sarei aspettato un eccezione, mentre invece la port > oltre un certo numero viene semplicemente interpretata come None > > >>> urlparse('redis://localhost:65535').port > 65535 > >>> urlparse('redis://localhost:65536').port is None > True > > sorprendentemente su python 2.6 funziona correttamente! Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from urlparse import urlparse >>> urlparse('redis://localhost:638012').port 638012 -marco
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python