public static object NextMethod(object self) { IEnumerator i = (IEnumerator)self; lock (i) { if (i.MoveNext()) { return(i.Current); } } throw PythonOps.StopIteration(); }