Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
check 'default_factory' attr on the type
  • Loading branch information
kwsp committed Oct 6, 2022
commit 4fcb8d0830d18e5c67aefcf2bcd1b3464f397eb8
2 changes: 1 addition & 1 deletion Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ def _asdict_inner(obj, dict_factory):
# generator (which is not true for namedtuples, handled
# above).
return type(obj)(_asdict_inner(v, dict_factory) for v in obj)
elif isinstance(obj, dict) and hasattr(obj, 'default_factory'):
elif isinstance(obj, dict) and hasattr(type(obj), 'default_factory'):
# obj is a defaultdict, which has a different constructor from
# dict as it requires the default_factory as its first arg.
# https://bugs.python.org/issue35540
Expand Down