Created originally on Bitbucket by pv
Was already merged in Bitbucket before import, marked as merged by the import user
CPython error state is threadlocal, but cpyext currently uses shared global state for it. This results to race conditions if GIL is released in cpyext extensions, see https://bitbucket.org/pypy/pypy/issues/2764
Fix this by moving the cpyext error state to ExecutionContext, in a similar way as for PyThreadState. Add a test checking for the issue.