public static IntPtr tp_iter(IntPtr ob) {
CLRObject co = GetManagedObject(ob) as CLRObject;
if (co == null) {
return Exceptions.RaiseTypeError("invalid object");
}
IEnumerable e = co.inst as IEnumerable;
IEnumerator o;
if (e != null) {
o = e.GetEnumerator();
}
else {
o = co.inst as IEnumerator;
if (o == null) {
string message = "iteration over non-sequence";
return Exceptions.RaiseTypeError(message);
}
}
return new Iterator(o).pyHandle;
}