Ivan Levkivskyi added the comment: Guido, Yury, it looks like I solved the puzzle. All the remaining problems are because of forward references. In particular, _ForwardRef keeps a reference to the frame where it was defined:
typing_globals = globals() frame = sys._getframe(1) while frame is not None and frame.f_globals is typing_globals: frame = frame.f_back assert frame is not None self.__forward_frame__ = frame This is old code from 2015 introduced to support __isinstance__ for forward refs. The latter is no more supported anyway, so that I believe this code should be removed. I will make a PR upstream soon. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28649> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com