kjd / idna

Internationalized Domain Names for Python (IDNA 2008 and UTS #46)
BSD 3-Clause "New" or "Revised" License
248 stars 91 forks source link

Fix all codec issues #145

Closed jribbens closed 1 year ago

jribbens commented 1 year ago

Closes #128, closes #134, closes #138, closes PR #144 (by incorporating it).

The attempt to use 'idna' as the codec name has been removed, as Python searches through the registered codecs in the order that they were registered, and the 'encodings' module (which provides the system 'idna') is imported as part of the interpreter start-up, so it will always win.

core.encode / core.decode have been changed so that instead of saying "if the input type is bytes, call s.decode" they say "if the input type is not str, call str(s)". This is important, not least because when you call b'foo'.decode('idna2008'), Python actually passes the codec decode function a memoryview object!

The codec tests file has been considerably expanded so that it will detect all the issues that were fixed, and so that all the codec entry points are tested.

kjd commented 1 year ago

Thanks Jon!

jribbens commented 1 year ago

I'm not sure what is up with the mypy tests on Python 3.5 and 3.6, as far as I can tell from the output, the diagnostic they are raising is simply flat-out wrong.