METADATA 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. Metadata-Version: 2.4
  2. Name: idna
  3. Version: 3.11
  4. Summary: Internationalized Domain Names in Applications (IDNA)
  5. Author-email: Kim Davies <kim+pypi@gumleaf.org>
  6. Requires-Python: >=3.8
  7. Description-Content-Type: text/x-rst
  8. License-Expression: BSD-3-Clause
  9. Classifier: Development Status :: 5 - Production/Stable
  10. Classifier: Intended Audience :: Developers
  11. Classifier: Intended Audience :: System Administrators
  12. Classifier: Operating System :: OS Independent
  13. Classifier: Programming Language :: Python
  14. Classifier: Programming Language :: Python :: 3
  15. Classifier: Programming Language :: Python :: 3 :: Only
  16. Classifier: Programming Language :: Python :: 3.8
  17. Classifier: Programming Language :: Python :: 3.9
  18. Classifier: Programming Language :: Python :: 3.10
  19. Classifier: Programming Language :: Python :: 3.11
  20. Classifier: Programming Language :: Python :: 3.12
  21. Classifier: Programming Language :: Python :: 3.13
  22. Classifier: Programming Language :: Python :: 3.14
  23. Classifier: Programming Language :: Python :: Implementation :: CPython
  24. Classifier: Programming Language :: Python :: Implementation :: PyPy
  25. Classifier: Topic :: Internet :: Name Service (DNS)
  26. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  27. Classifier: Topic :: Utilities
  28. License-File: LICENSE.md
  29. Requires-Dist: ruff >= 0.6.2 ; extra == "all"
  30. Requires-Dist: mypy >= 1.11.2 ; extra == "all"
  31. Requires-Dist: pytest >= 8.3.2 ; extra == "all"
  32. Requires-Dist: flake8 >= 7.1.1 ; extra == "all"
  33. Project-URL: Changelog, https://github.com/kjd/idna/blob/master/HISTORY.rst
  34. Project-URL: Issue tracker, https://github.com/kjd/idna/issues
  35. Project-URL: Source, https://github.com/kjd/idna
  36. Provides-Extra: all
  37. Internationalized Domain Names in Applications (IDNA)
  38. =====================================================
  39. Support for `Internationalized Domain Names in
  40. Applications (IDNA) <https://tools.ietf.org/html/rfc5891>`_
  41. and `Unicode IDNA Compatibility Processing
  42. <https://unicode.org/reports/tr46/>`_.
  43. The latest versions of these standards supplied here provide
  44. more comprehensive language coverage and reduce the potential of
  45. allowing domains with known security vulnerabilities. This library
  46. is a suitable replacement for the “encodings.idna”
  47. module that comes with the Python standard library, but which
  48. only supports an older superseded IDNA specification from 2003.
  49. Basic functions are simply executed:
  50. .. code-block:: pycon
  51. >>> import idna
  52. >>> idna.encode('ドメイン.テスト')
  53. b'xn--eckwd4c7c.xn--zckzah'
  54. >>> print(idna.decode('xn--eckwd4c7c.xn--zckzah'))
  55. ドメイン.テスト
  56. Installation
  57. ------------
  58. This package is available for installation from PyPI via the
  59. typical mechanisms, such as:
  60. .. code-block:: bash
  61. $ python3 -m pip install idna
  62. Usage
  63. -----
  64. For typical usage, the ``encode`` and ``decode`` functions will take a
  65. domain name argument and perform a conversion to ASCII compatible encoding
  66. (known as A-labels), or to Unicode strings (known as U-labels)
  67. respectively.
  68. .. code-block:: pycon
  69. >>> import idna
  70. >>> idna.encode('ドメイン.テスト')
  71. b'xn--eckwd4c7c.xn--zckzah'
  72. >>> print(idna.decode('xn--eckwd4c7c.xn--zckzah'))
  73. ドメイン.テスト
  74. Conversions can be applied at a per-label basis using the ``ulabel`` or
  75. ``alabel`` functions if necessary:
  76. .. code-block:: pycon
  77. >>> idna.alabel('测试')
  78. b'xn--0zwm56d'
  79. Compatibility Mapping (UTS #46)
  80. +++++++++++++++++++++++++++++++
  81. This library provides support for `Unicode IDNA Compatibility
  82. Processing <https://unicode.org/reports/tr46/>`_ which normalizes input from
  83. different potential ways a user may input a domain prior to performing the IDNA
  84. conversion operations. This functionality, known as a
  85. `mapping <https://tools.ietf.org/html/rfc5895>`_, is considered by the
  86. specification to be a local user-interface issue distinct from IDNA
  87. conversion functionality.
  88. For example, “Königsgäßchen” is not a permissible label as *LATIN
  89. CAPITAL LETTER K* is not allowed (nor are capital letters in general).
  90. UTS 46 will convert this into lower case prior to applying the IDNA
  91. conversion.
  92. .. code-block:: pycon
  93. >>> import idna
  94. >>> idna.encode('Königsgäßchen')
  95. ...
  96. idna.core.InvalidCodepoint: Codepoint U+004B at position 1 of 'Königsgäßchen' not allowed
  97. >>> idna.encode('Königsgäßchen', uts46=True)
  98. b'xn--knigsgchen-b4a3dun'
  99. >>> print(idna.decode('xn--knigsgchen-b4a3dun'))
  100. königsgäßchen
  101. Exceptions
  102. ----------
  103. All errors raised during the conversion following the specification
  104. should raise an exception derived from the ``idna.IDNAError`` base
  105. class.
  106. More specific exceptions that may be generated as ``idna.IDNABidiError``
  107. when the error reflects an illegal combination of left-to-right and
  108. right-to-left characters in a label; ``idna.InvalidCodepoint`` when
  109. a specific codepoint is an illegal character in an IDN label (i.e.
  110. INVALID); and ``idna.InvalidCodepointContext`` when the codepoint is
  111. illegal based on its position in the string (i.e. it is CONTEXTO or CONTEXTJ
  112. but the contextual requirements are not satisfied.)
  113. Building and Diagnostics
  114. ------------------------
  115. The IDNA and UTS 46 functionality relies upon pre-calculated lookup
  116. tables for performance. These tables are derived from computing against
  117. eligibility criteria in the respective standards using the command-line
  118. script ``tools/idna-data``.
  119. This tool will fetch relevant codepoint data from the Unicode repository
  120. and perform the required calculations to identify eligibility. There are
  121. three main modes:
  122. * ``idna-data make-libdata``. Generates ``idnadata.py`` and
  123. ``uts46data.py``, the pre-calculated lookup tables used for IDNA and
  124. UTS 46 conversions. Implementers who wish to track this library against
  125. a different Unicode version may use this tool to manually generate a
  126. different version of the ``idnadata.py`` and ``uts46data.py`` files.
  127. * ``idna-data make-table``. Generate a table of the IDNA disposition
  128. (e.g. PVALID, CONTEXTJ, CONTEXTO) in the format found in Appendix
  129. B.1 of RFC 5892 and the pre-computed tables published by `IANA
  130. <https://www.iana.org/>`_.
  131. * ``idna-data U+0061``. Prints debugging output on the various
  132. properties associated with an individual Unicode codepoint (in this
  133. case, U+0061), that are used to assess the IDNA and UTS 46 status of a
  134. codepoint. This is helpful in debugging or analysis.
  135. The tool accepts a number of arguments, described using ``idna-data
  136. -h``. Most notably, the ``--version`` argument allows the specification
  137. of the version of Unicode to be used in computing the table data. For
  138. example, ``idna-data --version 9.0.0 make-libdata`` will generate
  139. library data against Unicode 9.0.0.
  140. Additional Notes
  141. ----------------
  142. * **Packages**. The latest tagged release version is published in the
  143. `Python Package Index <https://pypi.org/project/idna/>`_.
  144. * **Version support**. This library supports Python 3.8 and higher.
  145. As this library serves as a low-level toolkit for a variety of
  146. applications, many of which strive for broad compatibility with older
  147. Python versions, there is no rush to remove older interpreter support.
  148. Support for older versions are likely to be removed from new releases
  149. as automated tests can no longer easily be run, i.e. once the Python
  150. version is officially end-of-life.
  151. * **Testing**. The library has a test suite based on each rule of the
  152. IDNA specification, as well as tests that are provided as part of the
  153. Unicode Technical Standard 46, `Unicode IDNA Compatibility Processing
  154. <https://unicode.org/reports/tr46/>`_.
  155. * **Emoji**. It is an occasional request to support emoji domains in
  156. this library. Encoding of symbols like emoji is expressly prohibited by
  157. the technical standard IDNA 2008 and emoji domains are broadly phased
  158. out across the domain industry due to associated security risks. For
  159. now, applications that need to support these non-compliant labels
  160. may wish to consider trying the encode/decode operation in this library
  161. first, and then falling back to using `encodings.idna`. See `the Github
  162. project <https://github.com/kjd/idna/issues/18>`_ for more discussion.
  163. * **Transitional processing**. Unicode 16.0.0 removed transitional
  164. processing so the `transitional` argument for the encode() method
  165. no longer has any effect and will be removed at a later date.