Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return "PyErr_Format" calls in "traits/ctraits.c" #1640

Merged
merged 7 commits into from
May 10, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions traits/ctraits.c
Original file line number Diff line number Diff line change
Expand Up @@ -1885,13 +1885,11 @@ getattr_generic(trait_object *trait, has_traits_object *obj, PyObject *name)
static PyObject *
getattr_event(trait_object *trait, has_traits_object *obj, PyObject *name)
{
PyErr_Format(
return PyErr_Format(
PyExc_AttributeError,
"The %.400U"
" trait of a %.50s instance is an 'event', which is write only.",
name, Py_TYPE(obj)->tp_name);

return NULL;
}

/*-----------------------------------------------------------------------------
Expand Down Expand Up @@ -2919,12 +2917,11 @@ trait_new(PyTypeObject *trait_type, PyObject *args, PyObject *kw)
return trait;
}

PyErr_Format(
return PyErr_Format(
TraitError,
"Invalid argument to trait constructor. The argument `kind` "
"must be an integer between 0 and 8 but a value of %d was provided.",
kind);
return NULL;
}

/*-----------------------------------------------------------------------------
Expand Down Expand Up @@ -3057,11 +3054,10 @@ _trait_set_default_value(trait_object *trait, PyObject *args)
}

if ((value_type < 0) || (value_type > MAXIMUM_DEFAULT_VALUE_TYPE)) {
PyErr_Format(
return PyErr_Format(
PyExc_ValueError,
"The default value type must be 0..%d, but %d was specified.",
MAXIMUM_DEFAULT_VALUE_TYPE, value_type);
return NULL;
}

/* Validate the value */
Expand Down