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 1 commit
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
8 changes: 4 additions & 4 deletions traits/ctraits.c
Original file line number Diff line number Diff line change
Expand Up @@ -2895,11 +2895,11 @@ static trait_setattr setattr_handlers[] = {
NULL};


trait_object *
PyObject *
trait_new(PyTypeObject *trait_type, PyObject *args, PyObject *kw)
{
int kind = 0;
trait_object *trait;
PyObject *trait;

if (kw != NULL && PyDict_Size(kw) != (Py_ssize_t) 0) {
PyErr_SetString(TraitError, "CTrait takes no keyword arguments");
Expand All @@ -2911,7 +2911,7 @@ trait_new(PyTypeObject *trait_type, PyObject *args, PyObject *kw)
}

if ((kind >= 0) && (kind <= 8)) {
trait = (trait_object *)PyType_GenericNew(trait_type, args, kw);
trait = (PyObject *)PyType_GenericNew(trait_type, args, kw);
Copy link
Member

@mdickinson mdickinson May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to do the cast at the return trait line. trait->getattr and trait->setattr won't make sense for a general PyObject *.

trait->getattr = getattr_handlers[kind];
trait->setattr = setattr_handlers[kind];
return trait;
Expand Down Expand Up @@ -5579,7 +5579,7 @@ static PyTypeObject trait_type = {
sizeof(trait_object) - sizeof(PyObject *), /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
(newfunc)trait_new /* tp_new */
trait_new /* tp_new */
};

/*-----------------------------------------------------------------------------
Expand Down