Hi,
I'm trying to get my head around the IronPython API by implementing a simple
work-around for what I believe is a bug in the next() builtin,which I
reported here: http://ironpython.codeplex.com/workitem/27383. This is my
first look inside IronPython so this question, I assume, is pretty basic.
How can I handle Python exceptions returned by TryInvokeUnaryOperator? I'm
currently trying to do this to implement the default value argument in the
next builtin.
public static object next(CodeContext/*!*/ context, object o) {
object value;
if (PythonTypeOps.TryInvokeUnaryOperator(context, o, "next", out
value)) {
return value;
}
throw PythonOps.TypeError("{0} object is not an iterator.",
PythonTypeOps.GetName(o));
}
public static object next(CodeContext/*!*/ context, object o, object
defaultVal) {
object value = next(context, o);
// This doesn't work.
if (value is StopIterationException) {
return defaultVal;
}
return value;
}
Thanks,
Tristan
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com