[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2021-11-29 Thread Irit Katriel


Irit Katriel  added the comment:

Reproduced on 3.11:

Traceback (most recent call last):
  File "/Users/iritkatriel/src/cpython-1/Lib/encodings/idna.py", line 165, in 
encode
raise UnicodeError("label empty or too long")
^
UnicodeError: label empty or too long

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/iritkatriel/src/cpython-1/Lib/socket.py", line 824, in 
create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
   ^^^
  File "/Users/iritkatriel/src/cpython-1/Lib/socket.py", line 955, in 
getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
   ^^^
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or 
too long)

--
nosy: +iritkatriel
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.3, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-05-05 Thread Mike Milkin

Mike Milkin added the comment:

Moved the conditional logic out of the method.  There are no tests for ToASCII 
function and I was not comfortable making changes to it without adding tests.

--
Added file: http://bugs.python.org/file30139/Issue9682-5513.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-27 Thread Mike Milkin

Mike Milkin added the comment:

Dave, let me know what you think of the tests, ill fix the rest of your 
comments.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-26 Thread R. David Murray

R. David Murray added the comment:

As I said in the review, thanks for working more on this.

For the reason for (3), look at the test just before the ones you added.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-22 Thread Mike Milkin

Mike Milkin added the comment:

There are a few of interesting parts. 
1.) I noticed that the ToASCII class is not tested.  
2.) I had some unreachable branches due to concatenation of constant variable 
ace_prefix.  
3) I also found it weird that we only check the max of labels[-1], but decided 
to perserve the original functionality.

--
Added file: http://bugs.python.org/file29984/Issue9682.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-22 Thread Mike Milkin

Changes by Mike Milkin mmil...@gmail.com:


Removed file: http://bugs.python.org/file29850/Issue9682-full.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-22 Thread Mike Milkin

Changes by Mike Milkin mmil...@gmail.com:


Removed file: http://bugs.python.org/file29984/Issue9682.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-22 Thread Mike Milkin

Changes by Mike Milkin mmil...@gmail.com:


Added file: http://bugs.python.org/file29985/Issue9682-42213.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-21 Thread Mike Milkin

Mike Milkin added the comment:

Sure ill modify the patch, thanks for the feedback.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-20 Thread R. David Murray

R. David Murray added the comment:

The message in both branches of the if talk about empty labels, which is 
probably my fault since I got the sense of the if wrong in my suggestion.  One 
of them should be about the label being too long.  The one that should be the 
'empty' message also doesn't read right to my eyes.  As I said I think it 
should be something like: 'empty label in %r % result.decode()'.

Also, in looking at the module code, there are several other places where the 
size check and simple message are used.  In all of these cases the string has 
already been confirmed to be (or converted to, in the case of the punycoding) 
ASCII.  So we can abstract this check into a function and call it from all 
those locations.

Do you want to update the patch accordingly, Mike?  It will need more tests.

--
assignee: loewis - 
type: enhancement - behavior
versions: +Python 3.3, Python 3.4 -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-14 Thread Mike Milkin

Mike Milkin added the comment:

I did not mean to take the decode out of the previos patch.  Sorry for the spam.

--
Added file: http://bugs.python.org/file29850/Issue9682-full.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-14 Thread Mike Milkin

Changes by Mike Milkin mmil...@gmail.com:


Removed file: http://bugs.python.org/file29834/Issue9682-full.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-13 Thread Mike Milkin

Mike Milkin added the comment:

This patch adds better exception messages.  
If any label other then  the last is empty or is too long the request is added 
to the exception message.
If the last label is over 64, the label is added to the exception message

--
keywords: +patch
nosy: +mmilkin
Added file: http://bugs.python.org/file29809/Issue9682.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-13 Thread R. David Murray

R. David Murray added the comment:

Thanks, Mike.  I made some review comments (you should have gotten an email, or 
look at them via the 'review' link on the patch).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-13 Thread Mike Milkin

Mike Milkin added the comment:

Made changes to to the tests and made changes to the error messages.

I think decode() is valid since the input is already ascii encoded.

--
Added file: http://bugs.python.org/file29834/Issue9682-full.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2010-08-26 Thread Georg Brandl

Changes by Georg Brandl ge...@python.org:


--
assignee:  - loewis

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2010-08-26 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
nosy: +giampaolo.rodola

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2010-08-26 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 why is it a UnicodeError? 

Because IDNA is an encoding, and codecs are supposed to raise UnicodeErrors. 
The string you are trying to encode is not supported in the encoding in 
question.

It would be possible to catch the UnicodeError, and re-raise it as a socket 
error in the socket module.

 I would expect a ValueError.

Notice that a UnicodeError *is* a ValueError.

 Could we perhaps change it to 'domain name subpart'?

No. As you point out, label is the established, wide-spread, technical, 
RFC-supported term for the thing in question. domain name subpart is an 
ad-hoc wording that nobody else uses. I fail to see the advantage.

It would be possible to include the actual label into the exception (perhaps 
truncated if it's too long).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2010-08-26 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Ah, I wondered if it was something like that (encoding=UnicodeError).  It's 
not really a *unicode* error, it's a syntax error in the domain name 
construction (ie: it is invalid whether or not unicode is involved, it just 
isn't caught in 2.x for non-unicode domain names), but oh well.

As for 'label' vs 'domain subpart', I've never heard anyone refer to the parts 
of a domain as 'labels' even in technical conversations, but as I think about 
it further I haven't heard them referred to at all.  So I withdraw that 
suggestion :)

Putting the label in the error message would be a nice enhancement, but 
definitely low priority.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2010-08-26 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 Ah, I wondered if it was something like that
 (encoding=UnicodeError).  It's not really a *unicode* error, it's a
 syntax error in the domain name construction (ie: it is invalid
 whether or not unicode is involved, it just isn't caught in 2.x for
 non-unicode domain names), but oh well.

It's perhaps dubious whether IDNA is an encoding at all. Punycode
certainly is, but IDNA only applies to (DNS) names. However, if
you take the stance that IDNA converts Unicode names into bytes
names, and is therefore an encoding, then this encoding is undefined
for certain Unicode strings. If the encoding is undefined, the exception
is a UnicodeError (unless there are errors in the code
of the codec itself, such as MemoryErrors, but that's not the case
here).

--
title: socket.create_connection error message for domain subpart with invalid 
length is very confusing - socket.create_connection error message for domain 
subpart with invalid length is very confusing

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com