super(NumBinopNode, self).generate_evaluation_code(code)
if self.overflow_check:
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.funcstate.release_temp(self.overflow_bit)
zero_test = "%s == 0" % self.operand2.result()
code.putln("if (unlikely(%s)) {" % zero_test)
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.putln(code.error_goto(self.pos))
code.putln("}")
self.operand2.result(), type_of_op2,
self.operand1.result()))
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.putln(code.error_goto(self.pos))
code.putln("}")
arg_result, arg_result))
else:
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' % (
code.error_goto(self.pos)))
code.putln('}')
code.putln(
"PyErr_Format(PyExc_NotImplementedError,")
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(
"return -1;")
code.putln(
code.putln(
"PyErr_Format(PyExc_NotImplementedError,")
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(
"return -1;")
code.putln(
code.putln(
"PyErr_Format(PyExc_NotImplementedError,")
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(
"return -1;")
code.putln(
code.putln(
"PyErr_Format(PyExc_NotImplementedError,")
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(
"return -1;")
code.putln(
cname = arg.entry.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,
code.error_goto(arg.pos)))
code.putln('}')
/////////////// BufferFallbackError ///////////////
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!");
}
}
#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
fail:
} else if (binding_func->type) {
/* Unbound method call */
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;
}
self = PyTuple_GET_ITEM(args, 0);
if (self && !is_classmethod && !is_staticmethod &&
!PyObject_IsInstance(self, binding_func->type)) {
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,
self->ob_type->tp_name);
goto __pyx_err;
return PyClassMethod_New(method);
}
#endif
- PyErr_Format(PyExc_TypeError,
- "Class-level classmethod() can only be called on "
- "a method_descriptor or instance method.");
+ PyErr_SetString(PyExc_TypeError,
+ "Class-level classmethod() can only be called on "
+ "a method_descriptor or instance method.");
return NULL;
}
const char *name, int exact)
{
if (unlikely(!type)) {
- PyErr_Format(PyExc_SystemError, "Missing type object");
+ PyErr_SetString(PyExc_SystemError, "Missing type object");
return 0;
}
if (none_allowed && obj == Py_None) return 1;
more_or_less = "exactly";
}
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,
(num_expected == 1) ? "" : "s", num_found);
}
return 1;
invalid_keyword_type:
PyErr_Format(PyExc_TypeError,
- "%s() keywords must be strings", function_name);
+ "%.200s() keywords must be strings", function_name);
return 0;
#endif
invalid_keyword:
PyErr_Format(PyExc_TypeError,
#if PY_MAJOR_VERSION < 3
- "%s() got an unexpected keyword argument '%s'",
+ "%.200s() got an unexpected keyword argument '%.200s'",
function_name, PyString_AsString(key));
#else
"%s() got an unexpected keyword argument '%U'",
goto bad;
invalid_keyword_type:
PyErr_Format(PyExc_TypeError,
- "%s() keywords must be strings", function_name);
+ "%.200s() keywords must be strings", function_name);
goto bad;
invalid_keyword:
PyErr_Format(PyExc_TypeError,
#if PY_MAJOR_VERSION < 3
- "%s() got an unexpected keyword argument '%s'",
+ "%.200s() got an unexpected keyword argument '%.200s'",
function_name, PyString_AsString(key));
#else
"%s() got an unexpected keyword argument '%U'",
goto bad;
if (!PyType_Check(result)) {
PyErr_Format(PyExc_TypeError,
- "%s.%s is not a type object",
+ "%.200s.%.200s is not a type object",
module_name, class_name);
goto bad;
}
}
else if ((size_t)basicsize != size) {
PyErr_Format(PyExc_ValueError,
- "%s.%s has the wrong size, try recompiling",
+ "%.200s.%.200s has the wrong size, try recompiling",
module_name, class_name);
goto bad;
}
cobj = PyDict_GetItemString(d, funcname);
if (!cobj) {
PyErr_Format(PyExc_ImportError,
- "%s does not export expected C function %s",
+ "%.200s does not export expected C function %.200s",
PyModule_GetName(module), funcname);
goto bad;
}
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0)
if (!PyCapsule_IsValid(cobj, sig)) {
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));
goto bad;
}
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
if (*s1 != *s2) {
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);
goto bad;
}
cobj = PyDict_GetItemString(d, name);
if (!cobj) {
PyErr_Format(PyExc_ImportError,
- "%s does not export expected C variable %s",
+ "%.200s does not export expected C variable %.200s",
PyModule_GetName(module), name);
goto bad;
}
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0)
if (!PyCapsule_IsValid(cobj, sig)) {
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));
goto bad;
}
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
if (*s1 != *s2) {
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);
goto bad;
}
if (spec & __Pyx_MEMVIEW_PTR) {
if (!buf->suboffsets || (buf->suboffsets && buf->suboffsets[dim] < 0)) {
PyErr_Format(PyExc_ValueError,
- "Buffer is not indirectly accessisble "
+ "Buffer is not indirectly accessible "
"in dimension %d.", dim);
goto fail;
}
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
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");
}
{{if access == 'Get'}}
"'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
{{else}}
- "'%.200s' object does not support slice %s",
+ "'%.200s' object does not support slice %.10s",
Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion");
{{endif}}
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
if (unlikely(!type)) {
- PyErr_Format(PyExc_SystemError, "Missing type object");
+ PyErr_SetString(PyExc_SystemError, "Missing type object");
return 0;
}
if (likely(PyObject_TypeCheck(obj, type)))
#if PY_MAJOR_VERSION >= 3
"name '%U' is not defined", name);
#else
- "name '%s' is not defined", PyString_AS_STRING(name));
+ "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
}
return result;
sizeof({{TYPE}}) == sizeof(long long)) {
return 0;
} 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;
}
}
if (check_bounds) {
Py_ssize_t size = PyBytes_GET_SIZE(bytes);
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;
}
}
if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
PyErr_Format(
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);
goto bad;
}
if (!PyLong_Check(res)) {
#endif
PyErr_Format(PyExc_TypeError,
- "__%s__ returned non-%s (type %.200s)",
+ "__%.4s__ returned non-%.4s (type %.200s)",
name, name, Py_TYPE(res)->tp_name);
Py_DECREF(res);
return NULL;
value = PyObject_GetItem(o, PYIDENT("{{member.name}}"));
if (!value) {
- PyErr_SetString(PyExc_ValueError, "No value specified for struct "
- "attribute '{{member.name}}'");
+ PyErr_Format(PyExc_ValueError, \
+ "No value specified for struct attribute '%.{{max(200, len(member.name))}}s'", "{{member.name}}");
goto bad;
}
{{attr}} = {{member.type.from_py_function}}(value);