[Python-Dev] Patch to use dict subclasses in eval(), exec

Guido van Rossum guido@python.org
2002年10月29日 07:09:22 -0500


> @@ -1696,9 +1701,10 @@
> 			}
> 			x = PyDict_GetItem(x, w);
> 			if (x == NULL) {
> -				x = PyDict_GetItem(f->f_globals, w);
> +				x = (fastglobals ? PyDict_GetItem : PyObject_GetItem)(f->f_globals, w);
> 				if (x == NULL) {
> -					x = PyDict_GetItem(f->f_builtins, w);
> +					if (!fastglobals) PyErr_Clear();
> +					x = (slowbuiltins ? PyObject_GetItem : PyDict_GetItem)(f->f_builtins, w);
> 					if (x == NULL) {
> 						format_exc_check_arg(
> 							 PyExc_NameError,

I don't see the extra DECREF here (and below) needed to compensate for
the fact that PyObject_GetItem() returns the object with incremented
refcount but PyDict_GetItem() doesn't.
What are you going to do with all the *other* places where
PyDict_GetItem() is used?
--Guido van Rossum (home page: http://www.python.org/~guido/)

AltStyle によって変換されたページ (->オリジナル) /