Message363884
I noticed that dataclasses.asdict seems to incorrectly reconstruct collections.Counter objects with the counter values as tuple keys.
eg:
In [1]: from collections import Counter
In [2]: from dataclasses import dataclass, asdict
In [3]: c = Counter()
In [4]: c['stuff'] += 1
In [5]: @dataclass
...: class Bob:
...: c: Counter
...:
In [6]: b = Bob(c)
In [7]: c
Out[7]: Counter({'stuff': 1})
In [9]: b.c
Out[9]: Counter({'stuff': 1})
In [10]: asdict(b)
Out[10]: {'c': Counter({('stuff', 1): 1})}
In [11]: asdict(b)['c']
Out[11]: Counter({('stuff', 1): 1})
The Counter gets reconstructed with its item tuples as keys.
This problem seems to have similar aspects to https://bugs.python.org/issue35540 |
|
Date |
User |
Action |
Args |
2020-03-11 06:13:03 | brad.scarlett@gmail.com | set | recipients:
+ brad.scarlett@gmail.com |
2020-03-11 06:13:03 | brad.scarlett@gmail.com | set | messageid: <1583907183.73.0.710103063731.issue39929@roundup.psfhosted.org> |
2020-03-11 06:13:03 | brad.scarlett@gmail.com | link | issue39929 messages |
2020-03-11 06:13:03 | brad.scarlett@gmail.com | create | |
|