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

Martin v. Löwis report at bugs.python.org
Thu Aug 26 23:30:55 CEST 2010


Martin v. Löwis <martin at 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 <report at bugs.python.org>
<http://bugs.python.org/issue9682>
_______________________________________


More information about the Python-bugs-list mailing list