fix bug in try-finally with class exceptions; declare different func pointers for different uses

This commit is contained in:
Guido van Rossum 1995-02-17 15:04:21 +00:00
parent fe299f9408
commit 1d339e8c35
1 changed files with 7 additions and 6 deletions

View File

@ -874,7 +874,7 @@ eval_code(co, globals, locals, owner, arg)
if (why == WHY_RETURN) if (why == WHY_RETURN)
retval = POP(); retval = POP();
} }
else if (is_stringobject(v)) { else if (is_stringobject(v) || is_classobject(v)) {
w = POP(); w = POP();
err_setval(v, w); err_setval(v, w);
DECREF(w); DECREF(w);
@ -2357,13 +2357,14 @@ assign_subscript(w, key, v) /* w[key] = v */
typeobject *tp = w->ob_type; typeobject *tp = w->ob_type;
sequence_methods *sq; sequence_methods *sq;
mapping_methods *mp; mapping_methods *mp;
int (*func)(); int (*func1)();
int (*func2)();
if ((mp = tp->tp_as_mapping) != NULL && if ((mp = tp->tp_as_mapping) != NULL &&
(func = mp->mp_ass_subscript) != NULL) { (func1 = mp->mp_ass_subscript) != NULL) {
return (*func)(w, key, v); return (*func1)(w, key, v);
} }
else if ((sq = tp->tp_as_sequence) != NULL && else if ((sq = tp->tp_as_sequence) != NULL &&
(func = sq->sq_ass_item) != NULL) { (func2 = sq->sq_ass_item) != NULL) {
if (!is_intobject(key)) { if (!is_intobject(key)) {
err_setstr(TypeError, err_setstr(TypeError,
"sequence subscript must be integer (assign or del)"); "sequence subscript must be integer (assign or del)");
@ -2377,7 +2378,7 @@ assign_subscript(w, key, v) /* w[key] = v */
return -1; return -1;
i += len; i += len;
} }
return (*func)(w, i, v); return (*func2)(w, i, v);
} }
} }
else { else {