@@ -761,6 +761,11 @@ private static bool ToArray(IntPtr value, Type obType, out object result, bool s
761
761
762
762
bool IsSeqObj = Runtime . PySequence_Check ( value ) ;
763
763
var len = IsSeqObj ? Runtime . PySequence_Size ( value ) : - 1 ;
764
+ if ( IsSeqObj && len < 0 )
765
+ {
766
+ // for the sequences, that explicitly deny calling __len__()
767
+ Exceptions . Clear ( ) ;
768
+ }
764
769
765
770
var IterObject = Runtime . PyObject_GetIter ( new BorrowedReference ( value ) ) ;
766
771
@@ -776,8 +781,9 @@ private static bool ToArray(IntPtr value, Type obType, out object result, bool s
776
781
777
782
var listType = typeof ( List < > ) ;
778
783
var constructedListType = listType . MakeGenericType ( elementType ) ;
779
- IList list = IsSeqObj ? ( IList ) Activator . CreateInstance ( constructedListType , new Object [ ] { ( int ) len } ) :
780
- ( IList ) Activator . CreateInstance ( constructedListType ) ;
784
+ IList list = IsSeqObj && len > 0
785
+ ? ( IList ) Activator . CreateInstance ( constructedListType , args : ( int ) len )
786
+ : ( IList ) Activator . CreateInstance ( constructedListType ) ;
781
787
NewReference item ;
782
788
783
789
while ( ! ( item = Runtime . PyIter_Next ( IterObject ) ) . IsNull ( ) )