Message109788
Attached is a simple Python 3 example script that defines a minimalist MutableMapping that simply wraps a dict, followed by:
x = MySimpleMapping(red=5)
y = x.keys()
z = x.keys() | {'orange'} x['blue'] = 7
print(list(z))
print(list(z))
Output:
['blue', 'red', 'orange']
[]
Expected Output:
['orange', 'red']
['orange', 'red']
The problem is that __or__ ends up returning a new KeysView wrapping a generator instead of returning a set.
To solve the problem, KeysView and ItemsView need to override _from_iterable to return a set instead of a new view. |
|
Date |
User |
Action |
Args |
2010-07-09 19:31:45 | stutzbach | set | recipients:
+ stutzbach |
2010-07-09 19:31:45 | stutzbach | set | messageid: <1278703905.18.0.125671722438.issue9214@psf.upfronthosting.co.za> |
2010-07-09 19:31:43 | stutzbach | link | issue9214 messages |
2010-07-09 19:31:43 | stutzbach | create | |
|