Ned Deily <> added the comment:

Thanks for the report.  The behavior you see can be further isolated to 

>>> import socket
>>> h = 
>>> ""
>>> socket.gethostbyname(h)
Traceback (most recent call last):
  File "/usr/lib/python3.6/encodings/", 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 "<stdin>", line 1, in <module>
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or 
too long)

Other socket module calls accepting host names fail similarly, such as 

nosy: +ned.deily
stage:  -> needs patch
title: Urllib proxy_bypass crashes for urls containing long basic auth strings 
-> socket module calls with long host names can fail with idna codec error
type: crash -> 
versions: +Python 3.7, Python 3.8

Python tracker <>
Python-bugs-list mailing list

Reply via email to