diff Objects/sliceobject.c @ 30333:b533224f1373 2.3

SF bug #800796: Difference between hash() and __hash__() slice(5).__hash__() now raises a TypeError.
author Raymond Hettinger <python@rcn.com>
date Fri, 05 Sep 2003 14:38:30 +0000
parents e094a03a80ff
children 97c97194e64b
line wrap: on
line diff
--- a/Objects/sliceobject.c	Thu Sep 04 19:02:20 2003 +0000
+++ b/Objects/sliceobject.c	Fri Sep 05 14:38:30 2003 +0000
@@ -278,6 +278,13 @@
 	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 @@
 	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 */