diff Python/ceval.c @ 58250:edfed0e32ced legacy-trunk

Issue #2333: Backport set and dict comprehensions syntax.
author Alexandre Vassalotti <alexandre@peadrop.com>
date Mon, 11 Jan 2010 22:36:12 +0000
parents c2fdf25329ff
children 76cf60e2d005
line wrap: on
line diff
--- a/Python/ceval.c	Mon Jan 11 17:15:13 2010 +0000
+++ b/Python/ceval.c	Mon Jan 11 22:36:12 2010 +0000
@@ -1455,6 +1455,17 @@
 			}
 			break;
 
+		case SET_ADD:
+			w = POP();
+			v = stack_pointer[-oparg];
+			err = PySet_Add(v, w);
+			Py_DECREF(w);
+			if (err == 0) {
+				PREDICT(JUMP_ABSOLUTE);
+				continue;
+			}
+			break;
+
 		case INPLACE_POWER:
 			w = POP();
 			v = TOP();
@@ -2223,6 +2234,21 @@
 			if (err == 0) continue;
 			break;
 
+		case MAP_ADD:
+			w = TOP();     /* key */
+			u = SECOND();  /* value */
+			STACKADJ(-2);
+			v = stack_pointer[-oparg];  /* dict */
+			assert (PyDict_CheckExact(v));
+			err = PyDict_SetItem(v, w, u);  /* v[w] = u */
+			Py_DECREF(u);
+			Py_DECREF(w);
+			if (err == 0) {
+				PREDICT(JUMP_ABSOLUTE);
+				continue;
+			}
+			break;
+
 		case LOAD_ATTR:
 			w = GETITEM(names, oparg);
 			v = TOP();