saghul/python-fibers — pull request #7 by geertj (2013-11-28 12:12:03+00:00)
Title: Simplify switching code.

This patch does away with the role of _global_state to identify the current
thread. Instead, the current thread is always identified by "__fibers_current"
in the thread state dictionary. The _global_state is now only used to pass
the source fiber and the value around a switch() call.

This fixes a bug whereby the current fiber was not correctly identified by
_global_state.current in case the thread of the previous fiber exited before
the current fiber would switch() to a third fiber.