Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-46750: only import idna when required on several common code paths #31328

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

slingamn
Copy link

@slingamn slingamn commented Feb 14, 2022

This fixes the linked issue. The reproduction case is:

python3 -c "import sys, urllib.request; urllib.request.urlopen('https://www.google.com'); assert 'encodings.idna' not in sys.modules"

One caveat is that this changes the exception type for socket.getaddrinfo (and probably other socket calls) when the hostname contains a null byte or codepoint: formerly, socket.getaddrinfo("a\u0000b", 443) or socket.getaddrinfo(b'a\x00b', 443) would throw socket.gaierror: [Errno -2] Name or service not known, but now they throw TypeError: host name must not contain null character.

I signed the CLA earlier today but it isn't recognized yet, I figured I might as well open the PR now.

Thanks very much for your time.

https://bugs.python.org/issue46750

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants