# Certain versions of pypy have a bug where clearing the exception stack # breaks the __exit__ function in a very peculiar way. This is currently # true for pypy 2.2.1 for instance. The second level of exception blocks # is necessary because pypy seems to forget to check if an exception # happened until the next bytecode instruction? BROKEN_PYPY_CTXMGR_EXIT = False if hasattr(sys, 'pypy_version_info'): class _Mgr(object): def __enter__(self): return self def __exit__(self, *args): sys.exc_clear() ^- this fails on pypy3 since 'sys.exc_clear()' is python2-ism. I guess it'd be good to make the whole block conditional to py2.
Yay, it's fixed upstream. I'll backport the patch.
commit 1abbfd2cf190c0b55fbd0a55f83de1ed3eeb8946 Author: Michał Górny <mgorny@gentoo.org> AuthorDate: Wed Nov 30 18:11:31 2016 Commit: Michał Górny <mgorny@gentoo.org> CommitDate: Wed Nov 30 19:05:40 2016 dev-python/flask: Backport PyPy3 fix, #601298