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 brandtbucher
Recipients Aaron Hall, brandtbucher, gvanrossum, josh.r, mark.dickinson, rhettinger, scoder, serhiy.storchaka, slam, steve.dower, xtreak
Date 2020-02-27.17:49:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1582825763.8.0.875939579822.issue36144@roundup.psfhosted.org>
In-reply-to
Content
> Im not sure if the dict(other) cast is the best way to go about it. Maybe this would work?

Yeah, I was imagining something like that... I used the cast for brevity in my reply but that probably wasn't helpful.

Note that for __or__, we probably want to check the type of the argument (for either dict or ChainMap, or maybe just Mapping), to keep it from working on an iterable of key-value pairs.

> I guess we need a __ror__ as well, in case there's some other mapping that doesn't implement __or__:

Agreed. Again, we can check for Mapping here to assure success for the copy() move.

> As a refinement, __or__ and __ror__ should perhaps check whether the operation can possibly succeed and return NotImplemented instead of raising? (Based on the type of other only, not its contents.)

Yup, see above. I think a check for Mapping should be fine.
History
Date User Action Args
2020-02-27 17:49:23brandtbuchersetrecipients: + brandtbucher, gvanrossum, rhettinger, mark.dickinson, scoder, serhiy.storchaka, steve.dower, josh.r, Aaron Hall, slam, xtreak
2020-02-27 17:49:23brandtbuchersetmessageid: <1582825763.8.0.875939579822.issue36144@roundup.psfhosted.org>
2020-02-27 17:49:23brandtbucherlinkissue36144 messages
2020-02-27 17:49:23brandtbuchercreate