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.
Created on 2011年06月04日 23:16 by vstinner, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| punycode_errors.patch | vstinner, 2011年06月15日 22:10 | review | ||
| Messages (8) | |||
|---|---|---|---|
| msg137666 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年06月04日 23:16 | |
b'abc\xff'.decode('punycode', 'ignore') raises the same error than b'abc\xff'.decode('punycode', 'replace') or b'abc\xff'.decode('punycode'): it uses the strict error handler, and simply ignores the error handler.
punycodec, as idna, should raise an exception if the error handler is different than strict.
|
|||
| msg137667 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年06月04日 23:17 | |
base64_codec.py uses an assertion to check the error handler: it should use an if+raise (assertions are ignored in optimized mode, python -O). |
|||
| msg138401 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年06月15日 22:10 | |
punycode_errors.patch: - raise an error if errors="replace": only accept strict and ignore - use errors to encode/decode to/from ASCII - add unit tests I don't think that the change should be documented, because punycode has no section in Doc/library/codecs.rst, and I hope that nobody uses something different than strict :-) |
|||
| msg138498 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年06月17日 10:55 | |
@Martin: Can you review my patch? |
|||
| msg138771 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2011年06月21日 07:55 | |
What's the point of disallowing the replace error handler? That's a slightly incompatible change, isn't it? |
|||
| msg138773 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年06月21日 09:38 | |
Oh, I forgot to give a little bit more details.
b'abc\xff-'.decode('punycode', 'ignore') and b'abc\xff-'.decode('punycode', 'replace') raise a UnicodeDecodeError: the error handler is just useless (ignored) here.
With my patch, b'abc\xff-'.decode('punycode', 'ignore') gives 'abc'. (If I change the code to accept replace) b'abc\xff-'.decode('punycode', 'replace') gives also 'abc', but 'replace' doesn't work correctly in the part after "-" contain illegal byte sequences.
For example, b'a\xff-\xffb\xffga\xff'.decode("punycode", "replace") gives 'a�', whereas I would expect 'a�é' or 'aé�'. b'a-bga\xff'.decode("punycode", "replace") gives 'aé' as b'a-bga'.decode("punycode", "replace"), whereas I would expect 'aé�' or something like that.
> What's the point of disallowing the replace error handler?
It's just that I'm unable to patch punycode decoder to support the replace handler. Do you want to "implement" it?
> That's a slightly incompatible change, isn't it?
I don't think so because I consider that the punycode decoder never supported error handlers (other than strict) in Python 3.
What do you think?
|
|||
| msg138801 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2011年06月21日 20:15 | |
> Oh, I forgot to give a little bit more details.
>
> b'abc\xff-'.decode('punycode', 'ignore') and
> b'abc\xff-'.decode('punycode', 'replace') raise a UnicodeDecodeError:
> the error handler is just useless (ignored) here.
That's not my point:
b"foo".decode("punycode","replace")
currently succeeds, but raises an UnicodeError under the patch.
|
|||
| msg206392 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2013年12月17日 01:52 | |
I prefer to not touch punycode right now, it works, there is no need to modify it. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:18 | admin | set | github: 56472 |
| 2013年12月17日 01:52:17 | vstinner | set | status: open -> closed resolution: wont fix messages: + msg206392 |
| 2011年06月21日 20:15:35 | loewis | set | messages: + msg138801 |
| 2011年06月21日 09:38:42 | vstinner | set | messages: + msg138773 |
| 2011年06月21日 07:55:13 | loewis | set | messages: + msg138771 |
| 2011年06月17日 10:55:15 | vstinner | set | messages: + msg138498 |
| 2011年06月15日 22:10:23 | vstinner | set | files:
+ punycode_errors.patch nosy: + loewis messages: + msg138401 keywords: + patch |
| 2011年06月05日 13:28:52 | r.david.murray | set | nosy:
+ r.david.murray |
| 2011年06月04日 23:17:40 | vstinner | set | messages: + msg137667 |
| 2011年06月04日 23:16:17 | vstinner | create | |