[3.7] bpo-35615: Fix crashes when copying a Weak{Key,Value}Dictionary. (GH-11384) by miss-islington · Pull Request #11785 · python/cpython

@ltfish @miss-islington

…honGH-11384)

Protect dict iterations by wrapping them with _IterationGuard in the
following methods:

- WeakValueDictionary.copy()
- WeakValueDictionary.__deepcopy__()
- WeakKeyDictionary.copy()
- WeakKeyDictionary.__deepcopy__()
(cherry picked from commit 96d37db)

Co-authored-by: Fish <ltfish@users.noreply.github.com>