Check for exceptions set by PyDict_GetItem().
diff --git a/Python/compile.c b/Python/compile.c
index 678a4de..464c953 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -959,6 +959,8 @@
 
 	v = PyDict_GetItem(dict, t);
 	if (!v) {
+                if (PyErr_Occurred())
+                        return -1;
 		arg = PyDict_Size(dict);
 		v = PyInt_FromLong(arg);
 		if (!v) {