[Pyrex] patch to avoid calling PyObject_TypeCheck in __Pyx_ArgTypeTest if object is None

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Apr 19 15:10:37 CEST 2006


Stefan Behnel wrote:

> this is a small patch that avoids calling PyObject_TypeCheck() from within
> __Pyx_ArgTypeTest in the case where obj is the not-allowed None value.

I don't see the point.

> Possible drawback: calling __Pyx_ArgTypeTest(obj, NoneType, 0, "obj") will
> result in the somewhat misleading error message "Argument 'obj' has incorrect
> type (expected NoneType, got NoneType)".

And that would be wrong. This should not be an error. If none_allowed
is false, it doesn't mean that None is never allowed, it means that
it's not allowed *in addition* to whatever type is expected. In the
rather peculiar case where you have an argument of type 'NoneType
not None', None is allowed by virtue of being of type NoneType.

But that would be an extremely strange declaration to write in
the first place, so I'm not inclined to worry about whether it
makes sense or not.

--
Greg



More information about the Pyrex mailing list