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: Refactor code using unicode_encode_call_errorhandler() in unicodeobject.c
Type: Stage: needs patch
Components: Unicode Versions: Python 3.3
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, vstinner
Priority: normal Keywords:

Created on 2011-10-18 11:50 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg145801 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-10-18 11:50
It's difficult to use unicode_encode_call_errorhandler() because the caller has to:

 - resize the output buffer (and check for integer overflow on the new size)
 - handle bytes and str for the replacement string: PyUnicode_EncodeDecimal() doesn't support bytes for example
 - encode replacement str: some encoders uses ASCII, unicode_encode_ucs1() uses Latin1, PyUnicode_EncodeCharmap() uses a recursive call (without check for infinite loop!), ... ; and raise a UnicodeEncodeError if the encoding fails

It would be nice to factorize this code.

I plan this implement this refactoring, it's just a reminder for me :-)
msg145802 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-10-18 12:05
+1
msg178909 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-01-03 02:55
I tried to factorize the code, but it is too complex. Each encoder handles errors differently. The most tricky is charmap: it reencodes the result of the error handler for non-ASCII characters. I'm not happy with the current situtation, but I don't see how to factorize easily the code, so I prefer to leave it unchanged. I close the issue.
History
Date User Action Args
2022-04-11 14:57:22adminsetgithub: 57418
2013-01-03 02:55:57vstinnersetstatus: open -> closed
resolution: wont fix
messages: + msg178909
2011-11-29 21:13:31vstinnerunlinkissue12892 dependencies
2011-10-26 04:34:05ezio.melottilinkissue12892 dependencies
2011-10-18 12:05:48ezio.melottisetnosy: + ezio.melotti

messages: + msg145802
stage: needs patch
2011-10-18 11:50:10vstinnercreate