python-idna
Port variant v14
Summary Int. Domain Names in Applications (3.14)
Package version 3.19
Homepage https://github.com/kjd/idna
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v13
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 19 AUG 2026, 18:47:48 UTC
Port created 30 MAY 2017, 20:17:50 UTC
Subpackage Descriptions
single # Internationalized Domain Names in Applications (IDNA) Support for [Internationalized Domain Names in Applications (IDNA)] and [Unicode IDNA Compatibility Processing]. It supersedes the standard library's `encodings.idna`, which only implements the 2003 specification, offering broader script coverage and limiting domains with known security vulnerabilities. ## Usage Package may be installed from [PyPI] via the typical methods (e.g. `python3 -m pip install idna`) For typical usage, the `encode` and `decode` functions will take a domain name argument and perform a conversion to ASCII-compatible encoding (known as A-labels), or to Unicode strings (known as U-labels) respectively. ```pycon >>> import idna >>> idna.encode('ドメイン.テスト') b'xn--eckwd4c7c.xn--zckzah' >>> print(idna.decode('xn--eckwd4c7c.xn--zckzah')) ドメイン.テスト ``` Conversions can be applied at a per-label basis using the `ulabel` or `alabel` functions for specialized use cases. ### Compatibility Mapping (UTS #46) This library provides support for [Unicode IDNA Compatibility Processing] which normalizes input from different potential ways a user may input a domain prior to performing the IDNA conversion operations. This functionality, known as a [mapping], is considered by the specification to be a local user-interface issue distinct from IDNA conversion functionality. For example, "Königsgäßchen" is not a permissible label as capital letters are not allowed. UTS #46 will convert this into lower case prior to applying the IDNA conversion. ```pycon >>> import idna >>> idna.encode('Königsgäßchen') ... idna.core.InvalidCodepoint: Codepoint U+004B at position 1 of 'Königsgäßchen' not allowed >>> idna.encode('Königsgäßchen', uts46=True) b'xn--knigsgchen-b4a3dun' >>> idna.decode('xn--knigsgchen-b4a3dun') 'königsgäßchen' ``` When performing a decode operation for display purposes, `decode()` accepts a `display=True` argument that leaves any `xn--` label that fails to decode unchanged. This is useful for user interface display where a domain is in use, the A-label form can be presented when it is not a valid IDN. ## Exceptions All errors raised during conversion derive from the `idna.IDNAError` base class. The more specific exceptions are: * `idna.IDNABidiError` — raised when a label contains an illegal combination of left-to-right and right-to-left characters. * `idna.InvalidCodepoint` — raised when a label contains a codepoint that is INVALID for IDNA. * `idna.InvalidCodepointContext` — raised when a CONTEXTO or CONTEXTJ codepoint appears in a position whose contextual requirements are not satisfied. Exceptions carry machine-readable attributes so that applications do not need to parse the message: `code` is a short, stable identifier for the rule that failed (listed below); and, when the failure can be attributed to a particular character, `text` (the label, or domain for UTS #46 processing, being validated), `codepoint` (the offending codepoint as an integer) and `position` (its 1-based index within `text`, as quoted in the message) are set. Each is `None` when it does not apply. Message wording is not part of the API and may change. ```pycon >>> try: ... idna.encode('Königsgäßchen') ... except idna.IDNAError as err: ... print(err.code, err.codepoint, err.position, err.text) disallowed_codepoint 75 1 Königsgäßchen ``` | `code` | Meaning | |---|---| | `input_too_long` | Input exceeds the library's defensive length limit and was not processed | | `label_too_long` | A label exceeds 63 octets |
Configuration Switches (platform-specific settings discarded)
PY313 OFF Build using Python 3.13 PY314 ON Build using Python 3.14
Package Dependencies by Type
Build (only) python314:dev:std
python-pip:single:v14
autoselect-python:single:std
Build and Runtime python314:primary:std
Download groups
main mirror://PYPIWHL/57/b0/0e52c878c53f245edd3a11020f20979b3f490f245af532c7cae3027754b5
Distribution File Information
815e7be7a7806d54abb586dc943addc79e8b2ee16915059658cbeff4b1b43bf4 68550 python-src/idna-3.19-py3-none-any.whl
Ports that require python-idna:v14
python-anyio:v14 Layer built on asyncio or trio libraries (3.14)
python-httpx:v14 Next generation HTTP client (3.14)
python-hyperlink:v14 Featureful, immutable, and correct URL (3.14)
python-requests:v14 Python HTTP for Humans (3.14)
python-url-normalize:v14 URL normalization for Python (3.14)
python-yarl:v14 Yet another URL library (3.14)