This code causes segfault. class Foo: pass foo = Foo() 1 in foo E:\python-dev>py a.py Exception exceptions.TypeError: "argument of type 'instance' is not iterable" in 'garbage collection' ignored Fatal Python error: unexpected exception during garbage collection This bug seems to be introduced by revision 45644 change for Objects/classobject.c # -1 (error) is converted to 0 (False) I think this can be fixed by attached patch. Thank you.
Logged In: YES user_id=33168 I fixed the problem slightly differently without casting, but rather checking the result. The patch also contains a test case.
Logged In: YES user_id=21627 It's not strictly necessary, IMO: PY_ITERSEARCH_CONTAINS is guaranteed to return -1, 0, 1, just as PySequence_Contains should. So the safe downcast is correct. IOW, your patch would have been correct, as well. I liked Neal's patch more, because it combines the error cases into a single return, and because it had a test case.