[Cython] [cython-users] which __new__ to use?
Stefan Behnel
stefan_ml at behnel.de
Sat Jan 11 06:46:17 CET 2014
Nils Bruin, 11.01.2014 00:38:
> In Objects/typeobject.c:2895 I find:
>
> static PyObject *
> object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
> {
> int err = 0;
> if (excess_args(args, kwds)) {
> if (type->tp_new != object_new &&
> type->tp_init != object_init)
> {
> err = PyErr_WarnEx(PyExc_DeprecationWarning,
> "object() takes no parameters",
> 1);
> }
> else if (type->tp_new != object_new ||
> type->tp_init == object_init)
> {
> PyErr_SetString(PyExc_TypeError,
> "object() takes no parameters");
> err = -1;
> }
> }
> if (err < 0)
> return NULL;
Ah, ok, that's newer than my Py2.7 copy then. Should have updated that ages
ago...
> so it would seem that the objects in sage have both tp_new and tp_init
> overridden (and warnings are enabled). I'm puzzled how `object_new` can
> even end up being called then.
Because of this change, I guess:
http://thread.gmane.org/gmane.comp.python.cython.devel/15140/focus=15145
Stefan
More information about the cython-devel
mailing list