[Python-Dev] cpython: PyUnicode_FromKindAndData() raises a ValueError if the kind is unknown
Georg Brandl
g.brandl at gmx.net
Sun Oct 2 16:21:49 CEST 2011
On 10/02/11 01:14, victor.stinner wrote:
> http://hg.python.org/cpython/rev/9124a00df142
> changeset: 72573:9124a00df142
> parent: 72571:fa0b1e50270f
> user: Victor Stinner <victor.stinner at haypocalc.com>
> date: Sat Oct 01 23:48:37 2011 +0200
> summary:
> PyUnicode_FromKindAndData() raises a ValueError if the kind is unknown
>
> files:
> Objects/unicodeobject.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
>
> diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
> --- a/Objects/unicodeobject.c
> +++ b/Objects/unicodeobject.c
> @@ -1211,7 +1211,7 @@
> case PyUnicode_4BYTE_KIND:
> return _PyUnicode_FromUCS4(buffer, size);
> }
> - assert(0);
> + PyErr_SetString(PyExc_ValueError, "invalid kind");
> return NULL;
> }
Is that really a ValueError? It should only be a ValueError if the user
could trigger that error. Otherwise it should be a SystemError.
Georg
More information about the Python-Dev
mailing list