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 roippi
Recipients roippi
Date 2014-08-13.20:52:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1407963163.14.0.392361410258.issue22192@psf.upfronthosting.co.za>
In-reply-to
Content
In python 3.4 these result in a TypeError:

  hash({}.keys())

  hash({}.items())

But this succeeds:

  hash({}.values())

The 2.7 backports of these - viewkeys, viewitems, and viewvalues respectively - behave equivalently.

See more discussion on StackOverflow: http://stackoverflow.com/questions/25293912/why-are-some-dict-views-hashable

The cause appears to be that key and item views implement rich comparisons, whereas values views do not.  Therefore dict_view objects use the default id()-based __hash__ implementation.

Possible fix: explicitly set tp_hash to PyObject_HashNotImplemented for PyDictValues_Type - and perhaps for the other two view types as well, for symmetry.
History
Date User Action Args
2014-08-13 20:52:43roippisetrecipients: + roippi
2014-08-13 20:52:43roippisetmessageid: <1407963163.14.0.392361410258.issue22192@psf.upfronthosting.co.za>
2014-08-13 20:52:43roippilinkissue22192 messages
2014-08-13 20:52:42roippicreate