Commit 219725ca authored by Stefan Behnel's avatar Stefan Behnel

clean up lots of places where exceptions are being raised to reduce the message building overhead

parent 683aa853
...@@ -8998,7 +8998,7 @@ class NumBinopNode(BinopNode): ...@@ -8998,7 +8998,7 @@ class NumBinopNode(BinopNode):
super(NumBinopNode, self).generate_evaluation_code(code) super(NumBinopNode, self).generate_evaluation_code(code)
if self.overflow_check: if self.overflow_check:
code.putln("if (unlikely(%s)) {" % self.overflow_bit) code.putln("if (unlikely(%s)) {" % self.overflow_bit)
code.putln('PyErr_Format(PyExc_OverflowError, "value too large");') code.putln('PyErr_SetString(PyExc_OverflowError, "value too large");')
code.putln(code.error_goto(self.pos)) code.putln(code.error_goto(self.pos))
code.putln("}") code.putln("}")
code.funcstate.release_temp(self.overflow_bit) code.funcstate.release_temp(self.overflow_bit)
...@@ -9233,7 +9233,7 @@ class DivNode(NumBinopNode): ...@@ -9233,7 +9233,7 @@ class DivNode(NumBinopNode):
zero_test = "%s == 0" % self.operand2.result() zero_test = "%s == 0" % self.operand2.result()
code.putln("if (unlikely(%s)) {" % zero_test) code.putln("if (unlikely(%s)) {" % zero_test)
code.put_ensure_gil() code.put_ensure_gil()
code.putln('PyErr_Format(PyExc_ZeroDivisionError, "%s");' % self.zero_division_message()) code.putln('PyErr_SetString(PyExc_ZeroDivisionError, "%s");' % self.zero_division_message())
code.put_release_ensured_gil() code.put_release_ensured_gil()
code.putln(code.error_goto(self.pos)) code.putln(code.error_goto(self.pos))
code.putln("}") code.putln("}")
...@@ -9248,7 +9248,7 @@ class DivNode(NumBinopNode): ...@@ -9248,7 +9248,7 @@ class DivNode(NumBinopNode):
self.operand2.result(), type_of_op2, self.operand2.result(), type_of_op2,
self.operand1.result())) self.operand1.result()))
code.put_ensure_gil() code.put_ensure_gil()
code.putln('PyErr_Format(PyExc_OverflowError, "value too large to perform division");') code.putln('PyErr_SetString(PyExc_OverflowError, "value too large to perform division");')
code.put_release_ensured_gil() code.put_release_ensured_gil()
code.putln(code.error_goto(self.pos)) code.putln(code.error_goto(self.pos))
code.putln("}") code.putln("}")
...@@ -10599,7 +10599,7 @@ class CoerceIntToBytesNode(CoerceToPyTypeNode): ...@@ -10599,7 +10599,7 @@ class CoerceIntToBytesNode(CoerceToPyTypeNode):
arg_result, arg_result)) arg_result, arg_result))
else: else:
code.putln("if (%s > 255) {" % arg_result) code.putln("if (%s > 255) {" % arg_result)
code.putln('PyErr_Format(PyExc_OverflowError, ' code.putln('PyErr_SetString(PyExc_OverflowError, '
'"value too large to pack into a byte"); %s' % ( '"value too large to pack into a byte"); %s' % (
code.error_goto(self.pos))) code.error_goto(self.pos)))
code.putln('}') code.putln('}')
......
...@@ -1496,7 +1496,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1496,7 +1496,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln( code.putln(
"PyErr_Format(PyExc_NotImplementedError,") "PyErr_Format(PyExc_NotImplementedError,")
code.putln( code.putln(
' "Subscript assignment not supported by %s", Py_TYPE(o)->tp_name);') ' "Subscript assignment not supported by %.200s", Py_TYPE(o)->tp_name);')
code.putln( code.putln(
"return -1;") "return -1;")
code.putln( code.putln(
...@@ -1513,7 +1513,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1513,7 +1513,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln( code.putln(
"PyErr_Format(PyExc_NotImplementedError,") "PyErr_Format(PyExc_NotImplementedError,")
code.putln( code.putln(
' "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name);') ' "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);')
code.putln( code.putln(
"return -1;") "return -1;")
code.putln( code.putln(
...@@ -1563,7 +1563,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1563,7 +1563,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln( code.putln(
"PyErr_Format(PyExc_NotImplementedError,") "PyErr_Format(PyExc_NotImplementedError,")
code.putln( code.putln(
' "2-element slice assignment not supported by %s", Py_TYPE(o)->tp_name);') ' "2-element slice assignment not supported by %.200s", Py_TYPE(o)->tp_name);')
code.putln( code.putln(
"return -1;") "return -1;")
code.putln( code.putln(
...@@ -1580,7 +1580,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1580,7 +1580,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln( code.putln(
"PyErr_Format(PyExc_NotImplementedError,") "PyErr_Format(PyExc_NotImplementedError,")
code.putln( code.putln(
' "2-element slice deletion not supported by %s", Py_TYPE(o)->tp_name);') ' "2-element slice deletion not supported by %.200s", Py_TYPE(o)->tp_name);')
code.putln( code.putln(
"return -1;") "return -1;")
code.putln( code.putln(
......
...@@ -1965,7 +1965,7 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1965,7 +1965,7 @@ class FuncDefNode(StatNode, BlockNode):
cname = arg.entry.cname cname = arg.entry.cname
code.putln('if (unlikely(((PyObject *)%s) == Py_None)) {' % cname) code.putln('if (unlikely(((PyObject *)%s) == Py_None)) {' % cname)
code.putln('''PyErr_Format(PyExc_TypeError, "Argument '%s' must not be None"); %s''' % ( code.putln('''PyErr_Format(PyExc_TypeError, "Argument '%%s' must not be None", "%s"); %s''' % (
arg.name, arg.name,
code.error_goto(arg.pos))) code.error_goto(arg.pos)))
code.putln('}') code.putln('}')
......
...@@ -47,7 +47,7 @@ static void __Pyx_RaiseBufferFallbackError(void); /*proto*/ ...@@ -47,7 +47,7 @@ static void __Pyx_RaiseBufferFallbackError(void); /*proto*/
/////////////// BufferFallbackError /////////////// /////////////// BufferFallbackError ///////////////
static void __Pyx_RaiseBufferFallbackError(void) { static void __Pyx_RaiseBufferFallbackError(void) {
PyErr_Format(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
} }
...@@ -134,7 +134,7 @@ static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { ...@@ -134,7 +134,7 @@ static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
} }
#endif #endif
PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name); PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
#if PY_VERSION_HEX < 0x02060000 #if PY_VERSION_HEX < 0x02060000
fail: fail:
......
...@@ -973,7 +973,7 @@ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw) ...@@ -973,7 +973,7 @@ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
} else if (binding_func->type) { } else if (binding_func->type) {
/* Unbound method call */ /* Unbound method call */
if (argc < 1) { if (argc < 1) {
PyErr_Format(PyExc_TypeError, "Need at least one argument, 0 given."); PyErr_SetString(PyExc_TypeError, "Need at least one argument, 0 given.");
return NULL; return NULL;
} }
self = PyTuple_GET_ITEM(args, 0); self = PyTuple_GET_ITEM(args, 0);
...@@ -982,7 +982,7 @@ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw) ...@@ -982,7 +982,7 @@ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
if (self && !is_classmethod && !is_staticmethod && if (self && !is_classmethod && !is_staticmethod &&
!PyObject_IsInstance(self, binding_func->type)) { !PyObject_IsInstance(self, binding_func->type)) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"First argument should be of type %s, got %s.", "First argument should be of type %.200s, got %.200s.",
((PyTypeObject *) binding_func->type)->tp_name, ((PyTypeObject *) binding_func->type)->tp_name,
self->ob_type->tp_name); self->ob_type->tp_name);
goto __pyx_err; goto __pyx_err;
...@@ -1141,8 +1141,8 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { ...@@ -1141,8 +1141,8 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
return PyClassMethod_New(method); return PyClassMethod_New(method);
} }
#endif #endif
PyErr_Format(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"Class-level classmethod() can only be called on " "Class-level classmethod() can only be called on "
"a method_descriptor or instance method."); "a method_descriptor or instance method.");
return NULL; return NULL;
} }
...@@ -15,7 +15,7 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in ...@@ -15,7 +15,7 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in
const char *name, int exact) const char *name, int exact)
{ {
if (unlikely(!type)) { if (unlikely(!type)) {
PyErr_Format(PyExc_SystemError, "Missing type object"); PyErr_SetString(PyExc_SystemError, "Missing type object");
return 0; return 0;
} }
if (none_allowed && obj == Py_None) return 1; if (none_allowed && obj == Py_None) return 1;
...@@ -64,7 +64,7 @@ static void __Pyx_RaiseArgtupleInvalid( ...@@ -64,7 +64,7 @@ static void __Pyx_RaiseArgtupleInvalid(
more_or_less = "exactly"; more_or_less = "exactly";
} }
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)", "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)",
func_name, more_or_less, num_expected, func_name, more_or_less, num_expected,
(num_expected == 1) ? "" : "s", num_found); (num_expected == 1) ? "" : "s", num_found);
} }
...@@ -145,13 +145,13 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings( ...@@ -145,13 +145,13 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
return 1; return 1;
invalid_keyword_type: invalid_keyword_type:
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"%s() keywords must be strings", function_name); "%.200s() keywords must be strings", function_name);
return 0; return 0;
#endif #endif
invalid_keyword: invalid_keyword:
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
"%s() got an unexpected keyword argument '%s'", "%.200s() got an unexpected keyword argument '%.200s'",
function_name, PyString_AsString(key)); function_name, PyString_AsString(key));
#else #else
"%s() got an unexpected keyword argument '%U'", "%s() got an unexpected keyword argument '%U'",
...@@ -276,12 +276,12 @@ arg_passed_twice: ...@@ -276,12 +276,12 @@ arg_passed_twice:
goto bad; goto bad;
invalid_keyword_type: invalid_keyword_type:
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"%s() keywords must be strings", function_name); "%.200s() keywords must be strings", function_name);
goto bad; goto bad;
invalid_keyword: invalid_keyword:
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
"%s() got an unexpected keyword argument '%s'", "%.200s() got an unexpected keyword argument '%.200s'",
function_name, PyString_AsString(key)); function_name, PyString_AsString(key));
#else #else
"%s() got an unexpected keyword argument '%U'", "%s() got an unexpected keyword argument '%U'",
......
...@@ -267,7 +267,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class ...@@ -267,7 +267,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class
goto bad; goto bad;
if (!PyType_Check(result)) { if (!PyType_Check(result)) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"%s.%s is not a type object", "%.200s.%.200s is not a type object",
module_name, class_name); module_name, class_name);
goto bad; goto bad;
} }
...@@ -295,7 +295,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class ...@@ -295,7 +295,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class
} }
else if ((size_t)basicsize != size) { else if ((size_t)basicsize != size) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"%s.%s has the wrong size, try recompiling", "%.200s.%.200s has the wrong size, try recompiling",
module_name, class_name); module_name, class_name);
goto bad; goto bad;
} }
...@@ -330,14 +330,14 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (** ...@@ -330,14 +330,14 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**
cobj = PyDict_GetItemString(d, funcname); cobj = PyDict_GetItemString(d, funcname);
if (!cobj) { if (!cobj) {
PyErr_Format(PyExc_ImportError, PyErr_Format(PyExc_ImportError,
"%s does not export expected C function %s", "%.200s does not export expected C function %.200s",
PyModule_GetName(module), funcname); PyModule_GetName(module), funcname);
goto bad; goto bad;
} }
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0) #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0)
if (!PyCapsule_IsValid(cobj, sig)) { if (!PyCapsule_IsValid(cobj, sig)) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"C function %s.%s has wrong signature (expected %s, got %s)", "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj)); PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
goto bad; goto bad;
} }
...@@ -351,7 +351,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (** ...@@ -351,7 +351,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
if (*s1 != *s2) { if (*s1 != *s2) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"C function %s.%s has wrong signature (expected %s, got %s)", "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
PyModule_GetName(module), funcname, sig, desc); PyModule_GetName(module), funcname, sig, desc);
goto bad; goto bad;
} }
...@@ -431,14 +431,14 @@ static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, con ...@@ -431,14 +431,14 @@ static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, con
cobj = PyDict_GetItemString(d, name); cobj = PyDict_GetItemString(d, name);
if (!cobj) { if (!cobj) {
PyErr_Format(PyExc_ImportError, PyErr_Format(PyExc_ImportError,
"%s does not export expected C variable %s", "%.200s does not export expected C variable %.200s",
PyModule_GetName(module), name); PyModule_GetName(module), name);
goto bad; goto bad;
} }
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0) #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0)
if (!PyCapsule_IsValid(cobj, sig)) { if (!PyCapsule_IsValid(cobj, sig)) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"C variable %s.%s has wrong signature (expected %s, got %s)", "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj)); PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
goto bad; goto bad;
} }
...@@ -452,7 +452,7 @@ static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, con ...@@ -452,7 +452,7 @@ static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, con
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
if (*s1 != *s2) { if (*s1 != *s2) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"C variable %s.%s has wrong signature (expected %s, got %s)", "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
PyModule_GetName(module), name, sig, desc); PyModule_GetName(module), name, sig, desc);
goto bad; goto bad;
} }
......
...@@ -238,7 +238,7 @@ __pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec ...@@ -238,7 +238,7 @@ __pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec
if (spec & __Pyx_MEMVIEW_PTR) { if (spec & __Pyx_MEMVIEW_PTR) {
if (!buf->suboffsets || (buf->suboffsets && buf->suboffsets[dim] < 0)) { if (!buf->suboffsets || (buf->suboffsets && buf->suboffsets[dim] < 0)) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"Buffer is not indirectly accessisble " "Buffer is not indirectly accessible "
"in dimension %d.", dim); "in dimension %d.", dim);
goto fail; goto fail;
} }
......
...@@ -36,7 +36,7 @@ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); ...@@ -36,7 +36,7 @@ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack", "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
index, (index == 1) ? "" : "s"); index, (index == 1) ? "" : "s");
} }
...@@ -593,7 +593,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice( ...@@ -593,7 +593,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
{{if access == 'Get'}} {{if access == 'Get'}}
"'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name); "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
{{else}} {{else}}
"'%.200s' object does not support slice %s", "'%.200s' object does not support slice %.10s",
Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion"); Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion");
{{endif}} {{endif}}
...@@ -919,7 +919,7 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*pr ...@@ -919,7 +919,7 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*pr
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
if (unlikely(!type)) { if (unlikely(!type)) {
PyErr_Format(PyExc_SystemError, "Missing type object"); PyErr_SetString(PyExc_SystemError, "Missing type object");
return 0; return 0;
} }
if (likely(PyObject_TypeCheck(obj, type))) if (likely(PyObject_TypeCheck(obj, type)))
...@@ -972,7 +972,7 @@ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { ...@@ -972,7 +972,7 @@ static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
"name '%U' is not defined", name); "name '%U' is not defined", name);
#else #else
"name '%s' is not defined", PyString_AS_STRING(name)); "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif #endif
} }
return result; return result;
......
...@@ -231,7 +231,8 @@ static int __Pyx_check_sane_{{NAME}}(void) { ...@@ -231,7 +231,8 @@ static int __Pyx_check_sane_{{NAME}}(void) {
sizeof({{TYPE}}) == sizeof(long long)) { sizeof({{TYPE}}) == sizeof(long long)) {
return 0; return 0;
} else { } else {
PyErr_Format(PyExc_RuntimeError, "Bad size for int type %s: %d", "{{TYPE}}", (int) sizeof({{TYPE}})); PyErr_Format(PyExc_RuntimeError, \
"Bad size for int type %.{{max(60, len(TYPE))}}s: %d", "{{TYPE}}", (int) sizeof({{TYPE}}));
return 1; return 1;
} }
} }
......
...@@ -640,7 +640,7 @@ static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t i ...@@ -640,7 +640,7 @@ static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t i
if (check_bounds) { if (check_bounds) {
Py_ssize_t size = PyBytes_GET_SIZE(bytes); Py_ssize_t size = PyBytes_GET_SIZE(bytes);
if (unlikely(index >= size) | ((index < 0) & unlikely(index < -size))) { if (unlikely(index >= size) | ((index < 0) & unlikely(index < -size))) {
PyErr_Format(PyExc_IndexError, "string index out of range"); PyErr_SetString(PyExc_IndexError, "string index out of range");
return -1; return -1;
} }
} }
......
...@@ -95,7 +95,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { ...@@ -95,7 +95,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) {
if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
PyErr_Format( PyErr_Format(
PyExc_ValueError, PyExc_ValueError,
"This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii.", "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
default_encoding_c); default_encoding_c);
goto bad; goto bad;
} }
...@@ -263,7 +263,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { ...@@ -263,7 +263,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
if (!PyLong_Check(res)) { if (!PyLong_Check(res)) {
#endif #endif
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"__%s__ returned non-%s (type %.200s)", "__%.4s__ returned non-%.4s (type %.200s)",
name, name, Py_TYPE(res)->tp_name); name, name, Py_TYPE(res)->tp_name);
Py_DECREF(res); Py_DECREF(res);
return NULL; return NULL;
...@@ -319,8 +319,8 @@ static {{struct_type_decl}} {{funcname}}(PyObject * o) { ...@@ -319,8 +319,8 @@ static {{struct_type_decl}} {{funcname}}(PyObject * o) {
value = PyObject_GetItem(o, PYIDENT("{{member.name}}")); value = PyObject_GetItem(o, PYIDENT("{{member.name}}"));
if (!value) { if (!value) {
PyErr_SetString(PyExc_ValueError, "No value specified for struct " PyErr_Format(PyExc_ValueError, \
"attribute '{{member.name}}'"); "No value specified for struct attribute '%.{{max(200, len(member.name))}}s'", "{{member.name}}");
goto bad; goto bad;
} }
{{attr}} = {{member.type.from_py_function}}(value); {{attr}} = {{member.type.from_py_function}}(value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment