Closed
Description
Bug report
This is very similar to #79721
from dataclasses import dataclass, astuple
from typing import DefaultDict, List
from collections import defaultdict
@dataclass
class C:
mp: DefaultDict[str, List]
dd = defaultdict(list)
dd["x"].append(12)
c = C(mp=dd)
d = astuple(c) # throws "TypeError: first argument must be callable or None"
assert d == ({"x": [12]},)
assert d[0] is not c.mp # make sure defaultdict is copied
Basically applying the same fix for asdict
from #32056 to astuple
.
Your environment
- CPython versions tested on: 3.10.7
- Operating system and architecture: macOS, arm64