Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: kjd/idna
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.2
Choose a base ref
...
head repository: kjd/idna
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.3
Choose a head ref

Commits on May 29, 2021

  1. Copy the full SHA
    1fde515 View commit details

Commits on Jul 7, 2021

  1. Don't conjugate "domain" in Russian (#102)

    "домена" means "[of the] домен".
    verhovsky authored Jul 7, 2021
    Copy the full SHA
    3099725 View commit details

Commits on Aug 28, 2021

  1. Run the full test suite on GitHub actions

    GitHub actions now include:
    
    - Python 3.5
    - PyPy 3
    - mypy
    jdufresne committed Aug 28, 2021
    Copy the full SHA
    a8afe44 View commit details
  2. Run GitHub actions on all branches (#104)

    This allows contributors to easily run tests on their fork through
    GitHub actions before opening a pull requests.
    jdufresne authored Aug 28, 2021
    Copy the full SHA
    41a3acb View commit details

Commits on Sep 1, 2021

  1. Copy the full SHA
    780dcc3 View commit details

Commits on Sep 14, 2021

  1. Update to Unicode 14

    kjd committed Sep 14, 2021
    Copy the full SHA
    b22480c View commit details

Commits on Oct 3, 2021

  1. Copy the full SHA
    f50df51 View commit details
  2. Merge pull request #107 from kjd/unicode-14

    Update to Unicode 14
    kjd authored Oct 3, 2021
    Copy the full SHA
    d0116b5 View commit details
  3. Copy the full SHA
    e1023cb View commit details
  4. Merge pull request #111 from kjd/issue-108

    Raise IDNAError on non-ASCII A-Label (fixes #108)
    kjd authored Oct 3, 2021
    Copy the full SHA
    4bfc439 View commit details
  5. Copy the full SHA
    7aff89a View commit details
  6. Merge pull request #105 from jdufresne/gha-mypy

    Run the full test suite on GitHub actions
    kjd authored Oct 3, 2021
    Copy the full SHA
    c3383c9 View commit details
  7. Copy the full SHA
    4fdcc18 View commit details
  8. Merge pull request #112 from kjd/issue-109

    Raise IDNAError exception on invalid A-label (fixes #109)
    kjd authored Oct 3, 2021
    Copy the full SHA
    b91e138 View commit details
  9. Copy the full SHA
    8bbb873 View commit details

Commits on Oct 8, 2021

  1. Add support for Python 3.10

    hugovk committed Oct 8, 2021
    Copy the full SHA
    c551e31 View commit details

Commits on Oct 9, 2021

  1. Merge pull request #114 from hugovk/add-3.10

    Add support for Python 3.10
    kjd authored Oct 9, 2021
    Copy the full SHA
    5d9d384 View commit details

Commits on Oct 12, 2021

  1. Adjust documentation (issue #18)

    Moved some items around and added text about version compatibility
    and emoji domains
    kjd committed Oct 12, 2021
    Copy the full SHA
    e7c7563 View commit details
  2. Merge pull request #115 from kjd/deprecation-policy

    Adjust documentation (issue #18)
    kjd authored Oct 12, 2021
    Copy the full SHA
    784edd5 View commit details
  3. Update history for v3.3

    kjd committed Oct 12, 2021
    Copy the full SHA
    b200b2f View commit details
  4. Bump package version to 3.3

    kjd committed Oct 12, 2021
    Copy the full SHA
    9a68c90 View commit details
  5. Copy the full SHA
    3aed72b View commit details
  6. Merge pull request #116 from kjd/release-3.3

    Release 3.3
    kjd authored Oct 12, 2021
    Copy the full SHA
    522c0eb View commit details
Showing with 707 additions and 552 deletions.
  1. +26 −6 .github/workflows/python-package.yml
  2. +0 −29 .travis.yml
  3. +14 −0 HISTORY.rst
  4. +32 −22 README.rst
  5. +5 −10 idna/codec.py
  6. +3 −6 idna/compat.py
  7. +27 −39 idna/core.py
  8. +112 −25 idna/idnadata.py
  9. +4 −8 idna/intranges.py
  10. +1 −1 idna/package_data.py
  11. +478 −404 idna/uts46data.py
  12. +1 −0 setup.py
  13. +2 −0 tests/test_idna.py
  14. +2 −2 tools/idna-data
32 changes: 26 additions & 6 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -4,18 +4,38 @@
name: Python package

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
- push
- pull_request

jobs:
build:
mypy:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- '3.5'
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install mypy
- name: Check types with mypy
run: mypy --strict idna

build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
python-version: ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10', 'pypy3']

steps:
- uses: actions/checkout@v2
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

14 changes: 14 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -3,6 +3,20 @@
History
-------

3.3 (2021-10-13)
++++++++++++++++

- Update to Unicode 14.0.0
- Update to in-line type annotations
- Throw IDNAError exception correctly for some malformed input
- Advertise support for Python 3.10
- Improve testing regime on Github
- Fix Russian typo in documentation

Thanks to Jon Defresne, Hugo van Kemenade, Seth Michael Larson,
Patrick Ventuzelo and Boris Verhovsky for contributions to this
release.

3.2 (2021-05-29)
++++++++++++++++

54 changes: 32 additions & 22 deletions README.rst
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ This library also provides support for Unicode Technical Standard 46,

This acts as a suitable replacement for the “encodings.idna” module that
comes with the Python standard library, but which only supports the
old, deprecated IDNA specification (`RFC 3490 <https://tools.ietf.org/html/rfc3490>`_).
older superseded IDNA specification (`RFC 3490 <https://tools.ietf.org/html/rfc3490>`_).

Basic functions are simply executed:

@@ -23,14 +23,6 @@ Basic functions are simply executed:
>>> print(idna.decode('xn--eckwd4c7c.xn--zckzah'))
ドメイン.テスト
Packages
--------

The latest tagged release version is published in the PyPI repository:

.. image:: https://badge.fury.io/py/idna.svg
:target: https://badge.fury.io/py/idna

Installation
------------
@@ -47,10 +39,6 @@ Alternatively, you can install the package using the bundled setup script:
$ python setup.py install
This library works with Python 3.4 or later. Earlier versions of this
library support Python 2 - use "idna<3" in your requirements file if
you need this library for a Python 2 application.

Usage
-----
@@ -72,10 +60,10 @@ You may use the codec encoding and decoding methods using the
.. code-block:: pycon
>>> import idna.codec
>>> print('домена.испытание'.encode('idna'))
b'xn--80ahd1agd.xn--80akhbyknj4f'
>>> print(b'xn--80ahd1agd.xn--80akhbyknj4f'.decode('idna'))
домена.испытание
>>> print('домен.испытание'.encode('idna'))
b'xn--d1acufc.xn--80akhbyknj4f'
>>> print(b'xn--d1acufc.xn--80akhbyknj4f'.decode('idna'))
домен.испытание
Conversions can be applied at a per-label basis using the ``ulabel`` or ``alabel``
functions if necessary:
@@ -186,9 +174,31 @@ in computing the table data. For example, ``idna-data --version 9.0.0 make-libda
will generate library data against Unicode 9.0.0.


Testing
-------
Additional Notes
----------------

The library has a test suite based on each rule of the IDNA specification, as
well as tests that are provided as part of the Unicode Technical Standard 46,
`Unicode IDNA Compatibility Processing <https://unicode.org/reports/tr46/>`_.
* **Packages**. The latest tagged release version is published in the
`Python Package Index <https://pypi.org/project/idna/>`_.

* **Version support**. This library supports Python 3.5 and higher. As this library
serves as a low-level toolkit for a variety of applications, many of which strive
for broad compatibility with older Python versions, there is no rush to remove
older intepreter support. Removing support for older versions should be well
justified in that the maintenance burden has become too high.

* **Python 2**. Python 2 is supported by version 2.x of this library. While active
development of the version 2.x series has ended, notable issues being corrected
may be backported to 2.x. Use "idna<3" in your requirements file if you need this
library for a Python 2 application.

* **Testing**. The library has a test suite based on each rule of the IDNA specification, as
well as tests that are provided as part of the Unicode Technical Standard 46,
`Unicode IDNA Compatibility Processing <https://unicode.org/reports/tr46/>`_.

* **Emoji**. It is an occasional request to support emoji domains in this library. Encoding
of symbols like emoji is expressly prohibited by the technical standard IDNA 2008 and
emoji domains are broadly phased out across the domain industry due to associated security
risks. For now, applications that wish need to support these non-compliant labels may
wish to consider trying the encode/decode operation in this library first, and then falling
back to using `encodings.idna`. See `the Github project <https://github.com/kjd/idna/issues/18>`_
for more discussion.
15 changes: 5 additions & 10 deletions idna/codec.py
Original file line number Diff line number Diff line change
@@ -7,8 +7,7 @@

class Codec(codecs.Codec):

def encode(self, data, errors='strict'):
# type: (str, str) -> Tuple[bytes, int]
def encode(self, data: str, errors: str = 'strict') -> Tuple[bytes, int]:
if errors != 'strict':
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))

@@ -17,8 +16,7 @@ def encode(self, data, errors='strict'):

return encode(data), len(data)

def decode(self, data, errors='strict'):
# type: (bytes, str) -> Tuple[str, int]
def decode(self, data: bytes, errors: str = 'strict') -> Tuple[str, int]:
if errors != 'strict':
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))

@@ -28,8 +26,7 @@ def decode(self, data, errors='strict'):
return decode(data), len(data)

class IncrementalEncoder(codecs.BufferedIncrementalEncoder):
def _buffer_encode(self, data, errors, final): # type: ignore
# type: (str, str, bool) -> Tuple[str, int]
def _buffer_encode(self, data: str, errors: str, final: bool) -> Tuple[str, int]: # type: ignore
if errors != 'strict':
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))

@@ -62,8 +59,7 @@ def _buffer_encode(self, data, errors, final): # type: ignore
return result_str, size

class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
def _buffer_decode(self, data, errors, final): # type: ignore
# type: (str, str, bool) -> Tuple[str, int]
def _buffer_decode(self, data: str, errors: str, final: bool) -> Tuple[str, int]: # type: ignore
if errors != 'strict':
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))

@@ -103,8 +99,7 @@ class StreamReader(Codec, codecs.StreamReader):
pass


def getregentry():
# type: () -> codecs.CodecInfo
def getregentry() -> codecs.CodecInfo:
# Compatibility as a search_function for codecs.register()
return codecs.CodecInfo(
name='idna',
9 changes: 3 additions & 6 deletions idna/compat.py
Original file line number Diff line number Diff line change
@@ -2,15 +2,12 @@
from .codec import *
from typing import Any, Union

def ToASCII(label):
# type: (str) -> bytes
def ToASCII(label: str) -> bytes:
return encode(label)

def ToUnicode(label):
# type: (Union[bytes, bytearray]) -> str
def ToUnicode(label: Union[bytes, bytearray]) -> str:
return decode(label)

def nameprep(s):
# type: (Any) -> None
def nameprep(s: Any) -> None:
raise NotImplementedError('IDNA 2008 does not utilise nameprep protocol')

Loading