Skip to content

Commit cbcb624

Browse files
committed
copy.copy() of dict subclasses with slots didn't work on early 3.6.x
1 parent 77cff08 commit cbcb624

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

trio/_core/_instrumentation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
import types
33
import attr
4-
import copy
54
from typing import Any, Callable, Dict, List, Sequence, Iterator, TypeVar
65

76
from .._abc import Instrument
@@ -71,8 +70,8 @@ def as_mutable(self) -> "Hook":
7170
# We're in the middle of a call on this hook, so
7271
# we must replace it with a copy in order to avoid
7372
# a "dict changed size during iteration" error.
74-
replacement = copy.copy(self)
75-
replacement._in_call = 0
73+
replacement = Hook(self._name, self._parent)
74+
replacement.update(self)
7675
setattr(self._parent, self._name, replacement)
7776
return replacement
7877
return self

0 commit comments

Comments
 (0)