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 <1644854115.6.0.132786473021.issue46750@roundup.psfhosted.org>
In-reply-to
Content
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/client.py 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/ssl.py and _socket.getaddrinfo. Here's a one-line test case:

python3 -c "import sys, urllib.request; urllib.request.urlopen('https://www.google.com'); 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).
History
Date User Action Args
2022-02-14 15:55:15slingamnsetrecipients: + slingamn, christian.heimes
2022-02-14 15:55:15slingamnsetmessageid: <1644854115.6.0.132786473021.issue46750@roundup.psfhosted.org>
2022-02-14 15:55:15slingamnlinkissue46750 messages
2022-02-14 15:55:15slingamncreate