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

R. David Murray report at bugs.python.org
Wed Aug 25 20:08:13 CEST 2010


New submission from R. David Murray <rdmurray at bitdance.com>:

>>> socket.create_connection(('a..com', 25))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rdmurray/python/py3k/Lib/socket.py", line 300, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/home/rdmurray/python/py3k/Lib/encodings/idna.py", line 167, in encode
    result.extend(ToASCII(label))
  File "/home/rdmurray/python/py3k/Lib/encodings/idna.py", line 73, in ToASCII
    raise UnicodeError("label empty or too long")
UnicodeError: label empty or too long

I have two problems with this: why is it a UnicodeError?  (That confused me into going down a blind alley before finding my typo in the original context where I encountered this).  The other problem is the term 'label'.  I realize this is technically correct and precise, but I doubt most users will recognize it (I didn't remember what it meant until I looked it up).  Could we perhaps change it to 'domain name subpart'?

Note that in 2.x this gives 'name or service not known' unless the input string is unicode, in which case it gives the error above.  So in 2.x the UnicodeError was at least not totally dissociated from the cause of the error, but still strikes me as sub-optimal.  I would expect a ValueError.

----------
components: Library (Lib)
keywords: easy
messages: 114923
nosy: loewis, r.david.murray
priority: low
severity: normal
status: open
title: socket.create_connection error message for domain subpart with invalid length is very confusing
type: feature request
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9682>
_______________________________________


More information about the New-bugs-announce mailing list