This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author slingamn
Recipients christian.heimes, slingamn
Date 2022-02-14.15:55:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Importing the idna encoding has a significant time and memory cost. Therefore, the standard library tries to avoid importing it when it's not needed (i.e. when the domain name is already pure ASCII), e.g. in Lib/http/ and Modules/socketmodule.c with `idna_converter`.

However, there are code paths that still attempt to encode or decode as idna unconditionally, in particular Lib/ and _socket.getaddrinfo. Here's a one-line test case:

python3 -c "import sys, urllib.request; urllib.request.urlopen(''); assert 'encodings.idna' not in sys.modules"

These code paths can be converted using existing code to do the import conditionally (I'll send a PR).
Date User Action Args
2022-02-14 15:55:15slingamnsetrecipients: + slingamn, christian.heimes
2022-02-14 15:55:15slingamnsetmessageid: <>
2022-02-14 15:55:15slingamnlinkissue46750 messages
2022-02-14 15:55:15slingamncreate