[issue13209] Refactor code using unicode_encode_call_errorhandler() in unicodeobject.c

STINNER Victor report at bugs.python.org
Tue Oct 18 13:50:11 CEST 2011


New submission from STINNER Victor <victor.stinner at haypocalc.com>:

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 :-)

----------
components: Unicode
messages: 145801
nosy: haypo
priority: normal
severity: normal
status: open
title: Refactor code using unicode_encode_call_errorhandler() in unicodeobject.c
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13209>
_______________________________________


More information about the Python-bugs-list mailing list