Message231852
Regarding the patch below, isn't most of this redundant? ISTM that simply calling PyErr_SetString(...) should do all of this, including the exception chaining.
diff -r 23ab1197df0b Objects/genobject.c
--- a/Objects/genobject.c Wed Nov 19 13:21:40 2014 +0200
+++ b/Objects/genobject.c Thu Nov 20 16:47:59 2014 +1100
@@ -130,6 +130,23 @@
}
Py_CLEAR(result);
}
+ else if (!result)
+ {
+ if (PyErr_ExceptionMatches(PyExc_StopIteration))
+ {
+ PyObject *exc, *val, *val2, *tb;
+ PyErr_Fetch(&exc, &val, &tb);
+ PyErr_NormalizeException(&exc, &val, &tb);
+ Py_DECREF(exc);
+ Py_XDECREF(tb);
+ PyErr_SetString(PyExc_RuntimeError,
+ "generator raised StopIteration");
+ PyErr_Fetch(&exc, &val2, &tb);
+ PyErr_NormalizeException(&exc, &val2, &tb);
+ PyException_SetContext(val2, val);
+ PyErr_Restore(exc, val2, tb);
+ }
+ }
if (!result || f->f_stacktop == NULL) {
/* generator can't be rerun, so release the frame */ |
|
Date |
User |
Action |
Args |
2014-11-29 08:17:24 | scoder | set | recipients:
+ scoder, gvanrossum, rhettinger, belopolsky, vstinner, r.david.murray, python-dev, schlamar, Rosuav, serhiy.storchaka |
2014-11-29 08:17:24 | scoder | set | messageid: <1417249044.51.0.129824816768.issue22906@psf.upfronthosting.co.za> |
2014-11-29 08:17:24 | scoder | link | issue22906 messages |
2014-11-29 08:17:24 | scoder | create | |
|