[New-bugs-announce] [issue13452] PyUnicode_EncodeDecimal: reject error handlers different than strict

STINNER Victor report at bugs.python.org
Tue Nov 22 13:24:49 CET 2011

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

Error handling of PyUnicode_EncodeDecimal() is broken by design. The caller cannot know the size of the output buffer because each error handler produce a variable output, whereas the caller has to allocate 
this buffer and it is not possible to specify the size of the output buffer.

I propose to raise a ValueError if the error handler is different than "strict" and do this change in Python 2.7, 3.2 and 3.3.

In Python 2.7 code base, PyUnicode_EncodeDecimal() is always called with 
errors=NULL. In Python 3.x, the function is no more called.

Attached patch is for Python 3.2.

See also the issue #13093.

components: Unicode
files: encode_decimal_errors.patch
keywords: patch
messages: 148111
nosy: ezio.melotti, haypo, loewis, skrah
priority: normal
severity: normal
status: open
title: PyUnicode_EncodeDecimal: reject error handlers different than strict
versions: Python 2.7, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file23754/encode_decimal_errors.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list