summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-01-02 19:42:39 (GMT)
committerGuido van Rossum <guido@python.org>1995-01-02 19:42:39 (GMT)
commitefc8713428b1f132c7d4bdf849593eb3684e7586 (patch)
treea0baaf720fe682bd30d9857ec03d72fabc1867d0
parent3bbc62e9c25d4c006cd21d6b1314ccf0ba211382 (diff)
downloadcpython-efc8713428b1f132c7d4bdf849593eb3684e7586.zip
cpython-efc8713428b1f132c7d4bdf849593eb3684e7586.tar.gz
cpython-efc8713428b1f132c7d4bdf849593eb3684e7586.tar.bz2
* Objects/mappingobject.c (mappingremove): don't call
lookmapping() for empty dictionary
-rw-r--r--Objects/dictobject.c3
-rw-r--r--Objects/mappingobject.c3
2 files changed, 6 insertions, 0 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 89fd314..bb4e051 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -322,8 +322,11 @@ mappingremove(op, key)
if (hash == -1)
return -1;
mp = (mappingobject *)op;
+ if (((mappingobject *)op)->ma_table == NULL)
+ goto empty;
ep = lookmapping(mp, key, hash);
if (ep->me_value == NULL) {
+ empty:
err_setval(KeyError, key);
return -1;
}
diff --git a/Objects/mappingobject.c b/Objects/mappingobject.c
index 89fd314..bb4e051 100644
--- a/Objects/mappingobject.c
+++ b/Objects/mappingobject.c
@@ -322,8 +322,11 @@ mappingremove(op, key)
if (hash == -1)
return -1;
mp = (mappingobject *)op;
+ if (((mappingobject *)op)->ma_table == NULL)
+ goto empty;
ep = lookmapping(mp, key, hash);
if (ep->me_value == NULL) {
+ empty:
err_setval(KeyError, key);
return -1;
}