diff options
author | Guido van Rossum <guido@python.org> | 1991-12-10 13:52:46 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-12-10 13:52:46 (GMT) |
commit | 32c6cdf77605fced058c08259f6ce923ae248dfd (patch) | |
tree | c3d0afbabf38bd55486f6ea2ec848269800efb55 /Python | |
parent | 50afb7a2167c2f8c51b2453df0cdf692c1682723 (diff) | |
download | cpython-32c6cdf77605fced058c08259f6ce923ae248dfd.zip cpython-32c6cdf77605fced058c08259f6ce923ae248dfd.tar.gz cpython-32c6cdf77605fced058c08259f6ce923ae248dfd.tar.bz2 |
Added STORE_GLOBAL and DELETE_GLOBAL.
Exceptions may now also be tuples.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 7399623..b5a3f4c 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -523,6 +523,12 @@ eval_code(co, globals, locals, arg) case RAISE_EXCEPTION: v = POP(); w = POP(); + /* A tuple is equivalent to its first element here */ + while (is_tupleobject(w)) { + u = w; + w = gettupleitem(u, 0); + DECREF(u); + } if (!is_stringobject(w)) err_setstr(TypeError, "exceptions must be strings"); @@ -630,7 +636,7 @@ eval_code(co, globals, locals, arg) why = WHY_EXCEPTION; } else if (gettuplesize(v) != oparg) { - err_setstr(RuntimeError, + err_setstr(ValueError, "unpack tuple of wrong size"); why = WHY_EXCEPTION; } @@ -651,7 +657,7 @@ eval_code(co, globals, locals, arg) why = WHY_EXCEPTION; } else if (getlistsize(v) != oparg) { - err_setstr(RuntimeError, + err_setstr(ValueError, "unpack list of wrong size"); why = WHY_EXCEPTION; } @@ -682,6 +688,19 @@ eval_code(co, globals, locals, arg) DECREF(v); break; + case STORE_GLOBAL: + w = GETNAMEV(oparg); + v = POP(); + err = dict2insert(f->f_globals, w, v); + DECREF(v); + break; + + case DELETE_GLOBAL: + w = GETNAMEV(oparg); + if ((err = dict2remove(f->f_globals, w)) != 0) + err_setstr(NameError, getstringvalue(w)); + break; + case LOAD_CONST: x = GETCONST(oparg); INCREF(x); @@ -941,7 +960,7 @@ eval_code(co, globals, locals, arg) Python main loop. Don't do this for 'finally'. */ if (b->b_type == SETUP_EXCEPT) { -#if 0 /* Oops, this breaks too many things */ +#if 1 /* Oops, this breaks too many things */ sysset("exc_traceback", v); #endif sysset("exc_value", val); @@ -1539,7 +1558,8 @@ cmp_exception(err, v) int i, n; n = gettuplesize(v); for (i = 0; i < n; i++) { - if (err == gettupleitem(v, i)) + /* Test recursively */ + if (cmp_exception(err, gettupleitem(v, i))) return 1; } return 0; |