Stefan Behnel wrote: > Dag Sverre Seljebotn wrote: >> When releasing the GIL, we get a PyThreadState* pointing to our current >> thread state, in _save. > > That is true for the nogil-block case, but not for nogil functions. > > I don't see a way to retrieve the original thread state from a nogil > function without acquiring the GIL first (maybe I'm missing something). So > how would calling a function that raises an exception work from within a > nogil function?
No, you appear to be right, I didn't consider that :-( However as there is already a way of propagating exceptions [1], using return values, it appears to be orthogonal to the question of whether buffer access or int division should imply an automatic "with gil" section raising an exception. (We could try to get a patch into Python for PyErr_OccurredWithoutGIL, don't know if such a thing would be accepted -- it would be easy to write. And then only acquire a GIL in the current Python versions. After all, it would only happen for something which is currently not allowed.) [1] From what I can see it works ok, except for a highly unlikely race condition on the __pyx_filename/lineno/... which can corrupt the exception stack description. -- Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
