Kaydet (Commit) 046595e4 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

SF bug #800796: Difference between hash() and __hash__()

slice(5).__hash__() now raises a TypeError.
üst 41add170
......@@ -12,6 +12,8 @@ What's New in Python 2.3.1?
Core and builtins
-----------------
- Bug #800796: slice(1).__hash__() now raises a TypeError, unhashable type.
- Bug #603724: Pass an explicit buffer to setvbuf in PyFile_SetBufSize().
- Bug #795506: The % formatting operator did not support '%F' as
......
......@@ -278,6 +278,13 @@ slice_compare(PySliceObject *v, PySliceObject *w)
return result;
}
static long
slice_hash(PySliceObject *v)
{
PyErr_SetString(PyExc_TypeError, "unhashable type");
return -1L;
}
PyTypeObject PySlice_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* Number of items for varobject */
......@@ -293,7 +300,7 @@ PyTypeObject PySlice_Type = {
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
(hashfunc)slice_hash, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment