[Python-Dev] Py_END_ALLOW_THREADS and GetLastError()

"Martin v. Löwis" martin at v.loewis.de
Sat Jan 10 15:11:16 CET 2009


> Well, that's what you get for using globals

Please do take a look at the issue at hand before pointing fingers.
First, GetLastError() isn't a really a global (and neither is errno);
they are both thread-local. Next, there is really no choice to use
or not use errno - if you want to find out what the error is that has
occurred, you *have* to look at errno. Finally, in the case of
Py_END_ALLOW_THREADS, errno/GetLastError is typically read right after
the system call. However, you can't raise the Python exception before
Py_END_ALLOW_THREADS (which you seem to suggest as a solution), since
we must not call Python APIs without holding the GIL.

> Generally, I would discourage non-local errno use. My motivation is that MS 
> Windows CE simply doesn't have errno and MS Windows in general often uses 
> different ways to signal errors, so not using it would restrict the 
> conditionally compiled code further.

That sounds like an unrelated issue to the one at hand.

Regards,
Martin


More information about the Python-Dev mailing list