PySequence_Check on class instance

Sebastian Tusk sebastian.tusk at
Thu Mar 4 11:47:26 CET 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?


More information about the Python-list mailing list