You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Refactor code using unicode_encode_call_errorhandler() in unicodeobject.c #57418
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2013-01-03.02:55:57.671>created_at=<Date2011-10-18.11:50:10.558>labels= ['expert-unicode']
title='Refactor code using unicode_encode_call_errorhandler() in unicodeobject.c'updated_at=<Date2013-01-03.02:55:57.670>user='https://github.com/vstinner'
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 :-)
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.
Activity
vstinner commentedon Oct 18, 2011
It's difficult to use unicode_encode_call_errorhandler() because the caller has to:
It would be nice to factorize this code.
I plan this implement this refactoring, it's just a reminder for me :-)
ezio-melotti commentedon Oct 18, 2011
+1
vstinner commentedon Jan 3, 2013
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.