From: Victor Stinner Date: Mon, 3 Oct 2011 22:04:26 +0000 (+0200) Subject: Unicode: raise SystemError instead of ValueError or RuntimeError on invalid X-Git-Tag: v3.3.0a1~1356 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=016980454ea88bcac5f1cea246cb8a5c0e55dc5a;p=thirdparty%2FPython%2Fcpython.git Unicode: raise SystemError instead of ValueError or RuntimeError on invalid state --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 46578128bf92..cad9bfe85f83 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -898,7 +898,7 @@ _PyUnicode_Dirty(PyObject *unicode) { assert(_PyUnicode_CHECK(unicode)); if (Py_REFCNT(unicode) != 1) { - PyErr_SetString(PyExc_ValueError, + PyErr_SetString(PyExc_SystemError, "Cannot modify a string having more than 1 reference"); return -1; } @@ -926,7 +926,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start, how_many = Py_MIN(PyUnicode_GET_LENGTH(from), how_many); if (to_start + how_many > PyUnicode_GET_LENGTH(to)) { - PyErr_Format(PyExc_ValueError, + PyErr_Format(PyExc_SystemError, "Cannot write %zi characters at %zi " "in a string of %zi characters", how_many, to_start, PyUnicode_GET_LENGTH(to)); @@ -1015,7 +1015,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start, else invalid_kinds = 1; if (invalid_kinds) { - PyErr_Format(PyExc_ValueError, + PyErr_Format(PyExc_SystemError, "Cannot copy %s characters " "into a string of %s characters", unicode_kind_name(from), @@ -1562,7 +1562,7 @@ PyUnicode_FromKindAndData(int kind, const void *buffer, Py_ssize_t size) case PyUnicode_4BYTE_KIND: return _PyUnicode_FromUCS4(buffer, size); } - PyErr_SetString(PyExc_ValueError, "invalid kind"); + PyErr_SetString(PyExc_SystemError, "invalid kind"); return NULL; } @@ -1622,7 +1622,7 @@ _PyUnicode_AsKind(PyObject *s, unsigned int kind) len = PyUnicode_GET_LENGTH(s); skind = PyUnicode_KIND(s); if (skind >= kind) { - PyErr_SetString(PyExc_RuntimeError, "invalid widening attempt"); + PyErr_SetString(PyExc_SystemError, "invalid widening attempt"); return NULL; } switch(kind) { @@ -1660,7 +1660,7 @@ _PyUnicode_AsKind(PyObject *s, unsigned int kind) default: break; } - PyErr_SetString(PyExc_ValueError, "invalid kind"); + PyErr_SetString(PyExc_SystemError, "invalid kind"); return NULL; }