[Python-checkins] CVS: python/dist/src/Python ceval.c,2.165,2.166

Greg Stein gstein@lyra.org
2000年1月12日 15:00:16 -0800 (PST)


For the PyRun_File case, you've introduced a Py_DECREF() that wasn't there
before. Was that intended?
Also note that PyString_AS_STRING() and PyString_GETSIZE could be used
since the object must be a string.
Cheers,
-g
On 2000年1月12日, Guido van Rossum wrote:
>...
> *** ceval.c	1999年11月15日 19:29:33	2.165
> --- ceval.c	2000年01月12日 22:45:54	2.166
> ***************
> *** 2741,2745 ****
> 	PyObject *locals;
> {
> - 	char *s;
> 	int n;
> 	PyObject *v;
> --- 2741,2744 ----
> ***************
> *** 2778,2808 ****
> 		PyDict_SetItemString(globals, "__builtins__", f->f_builtins);
> 	if (PyCode_Check(prog)) {
> ! 		v = PyEval_EvalCode((PyCodeObject *) prog,
> ! 				 globals, locals);
> ! 		if (v == NULL)
> ! 			return -1;
> ! 		Py_DECREF(v);
> ! 		return 0;
> 	}
> ! 	if (PyFile_Check(prog)) {
> 		FILE *fp = PyFile_AsFile(prog);
> 		char *name = PyString_AsString(PyFile_Name(prog));
> ! 		if (PyRun_File(fp, name, Py_file_input,
> ! 			 globals, locals) == NULL)
> ! 			return -1;
> ! 		return 0;
> 	}
> ! 	s = PyString_AsString(prog);
> ! 	if ((int)strlen(s) != PyString_Size(prog)) {
> ! 		PyErr_SetString(PyExc_ValueError,
> ! 				"embedded '\0円' in exec string");
> ! 		return -1;
> 	}
> ! 	v = PyRun_String(s, Py_file_input, globals, locals);
> 	if (v == NULL)
> 		return -1;
> 	Py_DECREF(v);
> - 	if (plain)
> - 		PyFrame_LocalsToFast(f, 0);
> 	return 0;
> }
> --- 2777,2801 ----
> 		PyDict_SetItemString(globals, "__builtins__", f->f_builtins);
> 	if (PyCode_Check(prog)) {
> ! 		v = PyEval_EvalCode((PyCodeObject *) prog, globals, locals);
> 	}
> ! 	else if (PyFile_Check(prog)) {
> 		FILE *fp = PyFile_AsFile(prog);
> 		char *name = PyString_AsString(PyFile_Name(prog));
> ! 		v = PyRun_File(fp, name, Py_file_input, globals, locals);
> 	}
> ! 	else {
> ! 		char *s = PyString_AsString(prog);
> ! 		if ((int)strlen(s) != PyString_Size(prog)) {
> ! 			PyErr_SetString(PyExc_ValueError,
> ! 					"embedded '\0円' in exec string");
> ! 			return -1;
> ! 		}
> ! 		v = PyRun_String(s, Py_file_input, globals, locals);
> 	}
> ! 	if (plain)
> ! 		PyFrame_LocalsToFast(f, 0);
> 	if (v == NULL)
> 		return -1;
> 	Py_DECREF(v);
> 	return 0;
> }

-- 
Greg Stein, http://www.lyra.org/

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