• Dylan Trotter's avatar
    Make map() and zip() clean up after StopIteration · e97a8ec0
    Dylan Trotter authored
    This came to light because of this issue report:
    https://github.com/google/grumpy/issues/305
    
    Basically, map() and zip() were detecting StopIteration but were calling
    ExcRestore(nil, nil) in the wrong place, so under normal circumstances,
    exc info would be set to StopIteration after they returned.
    
    Normally this would not cause a problem, but the code in the bug report
    was calling a native function (time.Now()) subsequent to a map() and
    nativeInvoke checks ExcInfo() to determine whether the Go function
    manually triggered an exception. See:
    
    https://github.com/google/grumpy/blob/master/runtime/native.go#L572
    
    In this case, nativeInvoke was being fooled because exc info had been
    set previously. nativeInvoke should probably be smarter about this by
    resetting the exception before the native call.
    e97a8ec0
builtin_test.py 8.49 KB