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

Skip to content

Commit c6652ca

Browse files
committed
Merge: 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.
2 parents 5b5ee69 + 5864c9f commit c6652ca

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
@@ -1236,15 +1236,21 @@ the user: The application should transparently convert Unicode domain labels to
12361236
IDNA on the wire, and convert back ACE labels to Unicode before presenting them
12371237
to the user.
12381238

1239-
Python supports this conversion in several ways: The ``idna`` codec allows to
1240-
convert between Unicode and the ACE. Furthermore, the :mod:`socket` module
1239+
Python supports this conversion in several ways: the ``idna`` codec performs
1240+
conversion between Unicode and ACE, separating an input string into labels
1241+
based on the separator characters defined in `section 3.1`_ (1) of :rfc:`3490`
1242+
and converting each label to ACE as required, and conversely separating an input
1243+
byte string into labels based on the ``.`` separator and converting any ACE
1244+
labels found into unicode. Furthermore, the :mod:`socket` module
12411245
transparently converts Unicode host names to ACE, so that applications need not
12421246
be concerned about converting host names themselves when they pass them to the
12431247
socket module. On top of that, modules that have host names as function
12441248
parameters, such as :mod:`http.client` and :mod:`ftplib`, accept Unicode host
12451249
names (:mod:`http.client` then also transparently sends an IDNA hostname in the
12461250
:mailheader:`Host` field if it sends that field at all).
12471251

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

0 commit comments

Comments
 (0)