Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0fd2f8

Browse files
committed
Fix wording and clarify that the IDNA codec operates on full domain names.
Before reading the code to check, I wasn't sure if it operated on full domain names or just individual labels.
1 parent ce073cd commit e0fd2f8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Doc/library/codecs.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,15 +1185,21 @@ the user: The application should transparently convert Unicode domain labels to
11851185
IDNA on the wire, and convert back ACE labels to Unicode before presenting them
11861186
to the user.
11871187

1188-
Python supports this conversion in several ways: The ``idna`` codec allows to
1189-
convert between Unicode and the ACE. Furthermore, the :mod:`socket` module
1188+
Python supports this conversion in several ways: the ``idna`` codec performs
1189+
conversion between Unicode and ACE, separating an input string into labels
1190+
based on the separator characters defined in `section 3.1`_ (1) of :rfc:`3490`
1191+
and converting each label to ACE as required, and conversely separating an input
1192+
byte string into labels based on the ``.`` separator and converting any ACE
1193+
labels found into unicode. Furthermore, the :mod:`socket` module
11901194
transparently converts Unicode host names to ACE, so that applications need not
11911195
be concerned about converting host names themselves when they pass them to the
11921196
socket module. On top of that, modules that have host names as function
11931197
parameters, such as :mod:`http.client` and :mod:`ftplib`, accept Unicode host
11941198
names (:mod:`http.client` then also transparently sends an IDNA hostname in the
11951199
:mailheader:`Host` field if it sends that field at all).
11961200

1201+
.. _section 3.1: http://tools.ietf.org/html/rfc3490#section-3.1
1202+
11971203
When receiving host names from the wire (such as in reverse name lookup), no
11981204
automatic conversion to Unicode is performed: Applications wishing to present
11991205
such host names to the user should decode them to Unicode.

0 commit comments

Comments
 (0)