summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c9
-rw-r--r--Objects/listobject.c11
2 files changed, 17 insertions, 3 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 019f112..3b922a9 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1797,6 +1797,13 @@ dict_init(PyObject *self, PyObject *args, PyObject *kwds)
return result;
}
+static long
+dict_nohash(PyObject *self)
+{
+ PyErr_SetString(PyExc_TypeError, "dict objects are unhashable");
+ return -1;
+}
+
static PyObject *
dict_iter(dictobject *dict)
{
@@ -1827,7 +1834,7 @@ PyTypeObject PyDict_Type = {
0, /* tp_as_number */
&dict_as_sequence, /* tp_as_sequence */
&dict_as_mapping, /* tp_as_mapping */
- 0, /* tp_hash */
+ dict_nohash, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
diff --git a/Objects/listobject.c b/Objects/listobject.c
index b05fe27..dbbc4a9 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -1617,6 +1617,13 @@ list_init(PyListObject *self, PyObject *args, PyObject *kw)
return 0;
}
+static long
+list_nohash(PyObject *self)
+{
+ PyErr_SetString(PyExc_TypeError, "list objects are unhashable");
+ return -1;
+}
+
static char append_doc[] =
"L.append(object) -- append object to end";
static char extend_doc[] =
@@ -1681,7 +1688,7 @@ PyTypeObject PyList_Type = {
0, /* tp_as_number */
&list_as_sequence, /* tp_as_sequence */
0, /* tp_as_mapping */
- 0, /* tp_hash */
+ list_nohash, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
@@ -1771,7 +1778,7 @@ static PyTypeObject immutable_list_type = {
0, /* tp_as_number */
&immutable_list_as_sequence, /* tp_as_sequence */
0, /* tp_as_mapping */
- 0, /* tp_hash */
+ list_nohash, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */