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 2015年03月15日 21:59 by serhiy.storchaka, last changed 2022年04月11日 14:58 by admin.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| translate_error_handlers.patch | serhiy.storchaka, 2015年03月15日 21:59 | |||
| translate_error_handlers_2.patch | serhiy.storchaka, 2015年03月16日 06:45 | review | ||
| Messages (8) | |||
|---|---|---|---|
| msg238163 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2015年03月15日 21:59 | |
Proposed patch adds support of UnicodeTranslateError in standard error handlers "xmlcharrefreplace", "namereplace" and "surrogatepass". Support in "backslashreplace" was added in issue22286, support in "strict", "ignore" and "replace" was always, support in "surrogateescape" is unlikely possible. This can be used with issue18814. |
|||
| msg238180 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2015年03月16日 06:45 | |
Fixed a bug in "surrogatepass" with translating and added the versionchanged directive. |
|||
| msg238973 - (view) | Author: Martin Panter (martin.panter) * (Python committer) | Date: 2015年03月23日 02:34 | |
I think I saw your patch for Issue 18814 proposes to use UnicodeTranslateError. Is there any other case where it is used, either currently or in the past? All I know of it is the documentation, which says it is raised "during translating". Experimenting with the constructor reveals that the "object" attribute is only allowed to be a text string (not bytes). So perhaps "translating" actually means converting from text strings to text strings, like "rot-13". It would be nice if this were documented somewhere, rather than just saying translating is now supported. |
|||
| msg239018 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2015年03月23日 13:41 | |
No, currently UnicodeTranslateError is not used in the stdlib in 3.x. But it is documented and supported by some error handlers. I think it should be wider used in text-to-text translations similar to proposed in issue18814. |
|||
| msg239353 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2015年03月26日 21:52 | |
I'm sorry, I don't understand this issue. Could you please elaborate the use case? Why do you want to support more error handlers? str.translate() calls _PyUnicode_TranslateCharmap() with errors="ignore", it's not possible to choose the error handler.
Many codecs are implemented in Python and some of them are implemented with "charmap". Does this issue enhance the codecs implemented with "charmap"?
"a\udc80".encode("latin9", "surrogatepass") raises UnicodeEncodeError with and without the patch, b"\x81".decode("cp1252", "surrogatepass") raises UnicodeDecodeError with and without the patch.
Hum, I'm not sure that codecs.charmap_build() is related str.translate().
|
|||
| msg239355 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2015年03月26日 22:20 | |
str.encode, bytes.decode and str.translate are unrelated to UnicodeTranslateError. But str.transform could be. |
|||
| msg239357 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2015年03月26日 22:29 | |
Serhiy Storchaka added the comment: > str.encode, bytes.decode and str.translate are unrelated to UnicodeTranslateError. But str.transform could be. Can you please give an example of Python code to show your change? |
|||
| msg239358 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2015年03月26日 22:45 | |
issue18814 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:13 | admin | set | github: 67864 |
| 2015年03月26日 22:45:41 | serhiy.storchaka | set | messages: + msg239358 |
| 2015年03月26日 22:29:08 | vstinner | set | messages: + msg239357 |
| 2015年03月26日 22:20:59 | serhiy.storchaka | set | messages: + msg239355 |
| 2015年03月26日 21:52:05 | vstinner | set | nosy:
+ vstinner messages: + msg239353 |
| 2015年03月23日 13:41:39 | serhiy.storchaka | set | assignee: serhiy.storchaka messages: + msg239018 |
| 2015年03月23日 02:34:53 | martin.panter | set | messages: + msg238973 |
| 2015年03月20日 02:59:30 | martin.panter | set | nosy:
+ martin.panter |
| 2015年03月16日 06:45:11 | serhiy.storchaka | set | files:
+ translate_error_handlers_2.patch messages: + msg238180 |
| 2015年03月15日 22:09:04 | serhiy.storchaka | link | issue18814 dependencies |
| 2015年03月15日 21:59:08 | serhiy.storchaka | create | |