James Saryerwinnie <j...@jamesls.com> added the comment:
I ran into this as well also using the embedded distribution for windows (https://docs.python.org/3/using/windows.html#the-embeddable-package). socket.getaddrinfo() will encode unicode hostnames using idna and trigger this error if you call this function in threads: PS C:\Users\Administrator\Downloads\python-3.7.3-embed-amd64> cat .\repro.py import threading import socket def task(): try: socket.getaddrinfo('www.google.com', 443) except Exception as e: print("FAIL: %s" % e) raise threads = [] for i in range(50): t = threading.Thread(target=task) threads.append(t) for t in threads: t.start() for t in threads: t.join() print("DONE") PS C:\Users\Administrator\Downloads\python-3.7.3-embed-amd64> .\python.exe .\repro.py FAIL: unknown encoding: idna FAIL: unknown encoding: idna Exception in thread Thread-5: Traceback (most recent call last): File "D:\obj\Windows-Release\37amd64_Release\msi_python\zip_amd64\threading.py", line 917, in _bootstrap_inner File "D:\obj\Windows-Release\37amd64_Release\msi_python\zip_amd64\threading.py", line 865, in run File ".\repro.py", line 7, in task socket.getaddrinfo('www.google.com', 443) File "D:\obj\Windows-Release\37amd64_Release\msi_python\zip_amd64\socket.py", line 748, in getaddrinfo LookupError: unknown encoding: idna FAIL: unknown encoding: idna Exception in thread Thread-4: Traceback (most recent call last): File "D:\obj\Windows-Release\37amd64_Release\msi_python\zip_amd64\threading.py", line 917, in _bootstrap_inner File "D:\obj\Windows-Release\37amd64_Release\msi_python\zip_amd64\threading.py", line 865, in run File ".\repro.py", line 7, in task socket.getaddrinfo('www.google.com', 443) File "D:\obj\Windows-Release\37amd64_Release\msi_python\zip_amd64\socket.py", line 748, in getaddrinfo LookupError: unknown encoding: idna Exception in thread Thread-6: Traceback (most recent call last): File "D:\obj\Windows-Release\37amd64_Release\msi_python\zip_amd64\threading.py", line 917, in _bootstrap_inner File "D:\obj\Windows-Release\37amd64_Release\msi_python\zip_amd64\threading.py", line 865, in run File ".\repro.py", line 7, in task socket.getaddrinfo('www.google.com', 443) File "D:\obj\Windows-Release\37amd64_Release\msi_python\zip_amd64\socket.py", line 748, in getaddrinfo LookupError: unknown encoding: idna DONE Confirmed that adding u''.encode('idna') fixes this issue. ---------- nosy: +James.Saryerwinnie _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue29288> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com