This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author stutzbach
Recipients stutzbach
Date 2010-07-09.19:31:42
SpamBayes Score 9.4488634e-05
Marked as misclassified No
Message-id <1278703905.18.0.125671722438.issue9214@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2010-07-09 19:31:45stutzbachsetrecipients: + stutzbach
2010-07-09 19:31:45stutzbachsetmessageid: <1278703905.18.0.125671722438.issue9214@psf.upfronthosting.co.za>
2010-07-09 19:31:43stutzbachlinkissue9214 messages
2010-07-09 19:31:43stutzbachcreate