This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDNA codec simplification
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: doerwalter Nosy List: doerwalter, loewis
Priority: normal Keywords: patch

Created on 2006-03-18 15:52 by doerwalter, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
idna.diff doerwalter, 2006-03-18 15:52
Messages (4)
msg49756 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2006-03-18 15:52
This patch simplifies the idna codec. It moves the
encode and decode functionality out of the Codec class,
so that it can be reused by the stateless and the
incremental codecs. (See patch #1436130 for the history
of this patch).
msg49757 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-03-19 10:13
Logged In: YES 
user_id=21627

This patch is wrong (AFAICT). If I understand the
incremental API correctly, it should be possible to pass
chunks of the input to the incremental encoder;
concatenating the results should give the same string as if
I had passed the entire input at once. This doesn't work for
this patch:

py> u"dörwald.de".encode("idna")
'xn--drwald-wxa.de'
py> c = codecs.getincrementalencoder("idna")()
py> c.encode(u"dör")
'xn--dr-fka'
py> c.encode(u"wald.de")
'wald.de'

So in the first case, I get the (correct) result
'xn--drwald-wxa.de'; in the second case, I get the incorrect
result 'xn--dr-fkawald.de'.

To properly encode IDNA incrementally, you need to process
an entire label at a time (i.e. between two dots, 
msg49758 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2006-03-19 10:52
Logged In: YES 
user_id=89016

You're right, this patch doesn't change the codecs behaviour
at all (the StreamWriter has to same problem:
import sys, codecs

w = codecs.getwriter("idna")(sys.stdout)
w.write(u"dör")
w.write(u"wald.de")
)

I'll try to come up with a patch that implements a real
incremental encoder and decoder.
msg49759 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2006-04-14 18:27
Logged In: YES 
user_id=89016

r45401 now contains a proper incremental encoder and decoder.
History
Date User Action Args
2022-04-11 14:56:16adminsetgithub: 43051
2006-03-18 15:52:55doerwaltercreate