summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-09-05 14:27:30 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-09-05 14:27:30 (GMT)
commitb859c070efbf3c6fd5210c0ae0e4d5a3de4bf9b2 (patch)
tree9f22bd1f76d59c4187760134b55237dc46accdc8 /Objects
parenta1a1dba2d48a92ccd49fe7529bd5a02b5ada1cb2 (diff)
downloadcpython-b859c070efbf3c6fd5210c0ae0e4d5a3de4bf9b2.zip
cpython-b859c070efbf3c6fd5210c0ae0e4d5a3de4bf9b2.tar.gz
cpython-b859c070efbf3c6fd5210c0ae0e4d5a3de4bf9b2.tar.bz2
SF bug #800796: Difference between hash() and __hash__()
slice(5).__hash__() now raises a TypeError.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/sliceobject.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c
index 796df2b..c37af2b 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -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 */