mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	cleanup a bit
This commit is contained in:
		
							parent
							
								
									a567a7796b
								
							
						
					
					
						commit
						232ecb8918
					
				
					 1 changed files with 15 additions and 24 deletions
				
			
		|  | @ -3041,6 +3041,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, | ||||||
| 	register PyObject **fastlocals, **freevars; | 	register PyObject **fastlocals, **freevars; | ||||||
| 	PyThreadState *tstate = PyThreadState_GET(); | 	PyThreadState *tstate = PyThreadState_GET(); | ||||||
| 	PyObject *x, *u; | 	PyObject *x, *u; | ||||||
|  | 	int total_args = co->co_argcount + co->co_kwonlyargcount; | ||||||
| 
 | 
 | ||||||
| 	if (globals == NULL) { | 	if (globals == NULL) { | ||||||
| 		PyErr_SetString(PyExc_SystemError, | 		PyErr_SetString(PyExc_SystemError, | ||||||
|  | @ -3057,9 +3058,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, | ||||||
| 	fastlocals = f->f_localsplus; | 	fastlocals = f->f_localsplus; | ||||||
| 	freevars = f->f_localsplus + co->co_nlocals; | 	freevars = f->f_localsplus + co->co_nlocals; | ||||||
| 
 | 
 | ||||||
| 	if (co->co_argcount > 0 || | 	if (total_args || co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) { | ||||||
| 	    co->co_kwonlyargcount > 0 || |  | ||||||
| 	    co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) { |  | ||||||
| 		int i; | 		int i; | ||||||
| 		int n = argcount; | 		int n = argcount; | ||||||
| 		PyObject *kwdict = NULL; | 		PyObject *kwdict = NULL; | ||||||
|  | @ -3067,7 +3066,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, | ||||||
| 			kwdict = PyDict_New(); | 			kwdict = PyDict_New(); | ||||||
| 			if (kwdict == NULL) | 			if (kwdict == NULL) | ||||||
| 				goto fail; | 				goto fail; | ||||||
| 			i = co->co_argcount + co->co_kwonlyargcount; | 			i = total_args; | ||||||
| 			if (co->co_flags & CO_VARARGS) | 			if (co->co_flags & CO_VARARGS) | ||||||
| 				i++; | 				i++; | ||||||
| 			SETLOCAL(i, kwdict); | 			SETLOCAL(i, kwdict); | ||||||
|  | @ -3095,7 +3094,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, | ||||||
| 			u = PyTuple_New(argcount - n); | 			u = PyTuple_New(argcount - n); | ||||||
| 			if (u == NULL) | 			if (u == NULL) | ||||||
| 				goto fail; | 				goto fail; | ||||||
| 			SETLOCAL(co->co_argcount + co->co_kwonlyargcount, u); | 			SETLOCAL(total_args, u); | ||||||
| 			for (i = n; i < argcount; i++) { | 			for (i = n; i < argcount; i++) { | ||||||
| 				x = args[i]; | 				x = args[i]; | ||||||
| 				Py_INCREF(x); | 				Py_INCREF(x); | ||||||
|  | @ -3116,17 +3115,13 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, | ||||||
| 			/* Speed hack: do raw pointer compares. As names are
 | 			/* Speed hack: do raw pointer compares. As names are
 | ||||||
| 			   normally interned this should almost always hit. */ | 			   normally interned this should almost always hit. */ | ||||||
| 			co_varnames = ((PyTupleObject *)(co->co_varnames))->ob_item; | 			co_varnames = ((PyTupleObject *)(co->co_varnames))->ob_item; | ||||||
| 			for (j = 0; | 			for (j = 0; j < total_args; j++) { | ||||||
| 			     j < co->co_argcount + co->co_kwonlyargcount; |  | ||||||
| 			     j++) { |  | ||||||
| 				PyObject *nm = co_varnames[j]; | 				PyObject *nm = co_varnames[j]; | ||||||
| 				if (nm == keyword) | 				if (nm == keyword) | ||||||
| 					goto kw_found; | 					goto kw_found; | ||||||
| 			} | 			} | ||||||
| 			/* Slow fallback, just in case */ | 			/* Slow fallback, just in case */ | ||||||
| 			for (j = 0; | 			for (j = 0; j < total_args; j++) { | ||||||
| 			     j < co->co_argcount + co->co_kwonlyargcount; |  | ||||||
| 			     j++) { |  | ||||||
| 				PyObject *nm = co_varnames[j]; | 				PyObject *nm = co_varnames[j]; | ||||||
| 				int cmp = PyObject_RichCompareBool( | 				int cmp = PyObject_RichCompareBool( | ||||||
| 					keyword, nm, Py_EQ); | 					keyword, nm, Py_EQ); | ||||||
|  | @ -3138,15 +3133,13 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, | ||||||
| 			/* Check errors from Compare */ | 			/* Check errors from Compare */ | ||||||
| 			if (PyErr_Occurred()) | 			if (PyErr_Occurred()) | ||||||
| 				goto fail; | 				goto fail; | ||||||
| 			if (j >= co->co_argcount + co->co_kwonlyargcount) { | 			if (j >= total_args && kwdict == NULL) { | ||||||
| 				if (kwdict == NULL) { | 				PyErr_Format(PyExc_TypeError, | ||||||
| 					PyErr_Format(PyExc_TypeError, | 					     "%U() got an unexpected " | ||||||
| 					    "%U() got an unexpected " | 					     "keyword argument '%S'", | ||||||
| 					    "keyword argument '%S'", | 					     co->co_name, | ||||||
| 					    co->co_name, | 					     keyword); | ||||||
| 					    keyword); | 				goto fail; | ||||||
| 					goto fail; |  | ||||||
| 				} |  | ||||||
| 			} | 			} | ||||||
| 			PyDict_SetItem(kwdict, keyword, value); | 			PyDict_SetItem(kwdict, keyword, value); | ||||||
| 			continue; | 			continue; | ||||||
|  | @ -3164,9 +3157,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, | ||||||
| 			SETLOCAL(j, value); | 			SETLOCAL(j, value); | ||||||
| 		} | 		} | ||||||
| 		if (co->co_kwonlyargcount > 0) { | 		if (co->co_kwonlyargcount > 0) { | ||||||
| 			for (i = co->co_argcount; | 			for (i = co->co_argcount; i < total_args; i++) { | ||||||
| 			     i < co->co_argcount + co->co_kwonlyargcount; |  | ||||||
| 			     i++) { |  | ||||||
| 				PyObject *name, *def; | 				PyObject *name, *def; | ||||||
| 				if (GETLOCAL(i) != NULL) | 				if (GETLOCAL(i) != NULL) | ||||||
| 					continue; | 					continue; | ||||||
|  | @ -3232,7 +3223,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, | ||||||
| 		Py_UNICODE *cellname, *argname; | 		Py_UNICODE *cellname, *argname; | ||||||
| 		PyObject *c; | 		PyObject *c; | ||||||
| 
 | 
 | ||||||
| 		nargs = co->co_argcount + co->co_kwonlyargcount; | 		nargs = total_args; | ||||||
| 		if (co->co_flags & CO_VARARGS) | 		if (co->co_flags & CO_VARARGS) | ||||||
| 			nargs++; | 			nargs++; | ||||||
| 		if (co->co_flags & CO_VARKEYWORDS) | 		if (co->co_flags & CO_VARKEYWORDS) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Benjamin Peterson
						Benjamin Peterson