PySequence_Check on class instance

Sebastian Tusk sebastian.tusk at silver-style.com
Thu Mar 4 05:47:26 EST 2004


PySequence_Check returns 1 for instances of a simple class. Even if this 
class doesn't implement __len__ and __getitem__.

The following code thus fails with an exception for classes that doesn't 
implement the sequence protocol.

if (PySequence_Check( instance )) {
	int size = PySequence_Size( instance );
}

Is this intended behaviour or a bug?


Regards,
Sebastian




More information about the Python-list mailing list