diff Python/ceval.c @ 464:90300ca21200 legacy-trunk

Added STORE_GLOBAL and DELETE_GLOBAL. Exceptions may now also be tuples.
author Guido van Rossum <guido@python.org>
date Tue, 10 Dec 1991 13:52:46 +0000
parents b5fe6482072f
children dc0463453a64
line wrap: on
line diff
--- a/Python/ceval.c	Tue Dec 10 13:52:31 1991 +0000
+++ b/Python/ceval.c	Tue Dec 10 13:52:46 1991 +0000
@@ -523,6 +523,12 @@
 		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 @@
 				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 @@
 				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 @@
 			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 @@
 					   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 @@
 		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;