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
Next Next commit
Remove dict special case for now
  • Loading branch information
DavidCEllis committed Mar 24, 2023
commit b77c17ed417bb3621bf970a16a1ae6a88547ae54
23 changes: 7 additions & 16 deletions Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1316,22 +1316,13 @@ class C:

def _asdict_inner(obj, dict_factory):
if _is_dataclass_instance(obj):
if dict_factory is dict:
result = {}
for f in fields(obj):
value = getattr(obj, f.name)
if type(value) not in _ATOMIC_TYPES:
value = _asdict_inner(value, dict_factory)
result[f.name] = value
return result
else:
result = []
for f in fields(obj):
value = getattr(obj, f.name)
if type(value) not in _ATOMIC_TYPES:
value = _asdict_inner(value, dict_factory)
result.append((f.name, value))
return dict_factory(result)
result = []
for f in fields(obj):
value = getattr(obj, f.name)
if type(value) not in _ATOMIC_TYPES:
value = _asdict_inner(value, dict_factory)
result.append((f.name, value))
return dict_factory(result)
elif isinstance(obj, tuple) and hasattr(obj, '_fields'):
# obj is a namedtuple. Recurse into it, but the returned
# object is another namedtuple of the same type. This is
Expand Down