* Objects/mappingobject.c (mappingremove): don't call

lookmapping() for empty dictionary
This commit is contained in:
Guido van Rossum 1995-01-02 19:42:39 +00:00
parent 3bbc62e9c2
commit efc8713428
2 changed files with 6 additions and 0 deletions

View File

@ -322,8 +322,11 @@ mappingremove(op, key)
if (hash == -1) if (hash == -1)
return -1; return -1;
mp = (mappingobject *)op; mp = (mappingobject *)op;
if (((mappingobject *)op)->ma_table == NULL)
goto empty;
ep = lookmapping(mp, key, hash); ep = lookmapping(mp, key, hash);
if (ep->me_value == NULL) { if (ep->me_value == NULL) {
empty:
err_setval(KeyError, key); err_setval(KeyError, key);
return -1; return -1;
} }

View File

@ -322,8 +322,11 @@ mappingremove(op, key)
if (hash == -1) if (hash == -1)
return -1; return -1;
mp = (mappingobject *)op; mp = (mappingobject *)op;
if (((mappingobject *)op)->ma_table == NULL)
goto empty;
ep = lookmapping(mp, key, hash); ep = lookmapping(mp, key, hash);
if (ep->me_value == NULL) { if (ep->me_value == NULL) {
empty:
err_setval(KeyError, key); err_setval(KeyError, key);
return -1; return -1;
} }