mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Issue #28257: Improved error message when pass a non-iterable as
a var-positional argument. Added opcode BUILD_TUPLE_UNPACK_WITH_CALL.
This commit is contained in:
		
							parent
							
								
									8f0f205649
								
							
						
					
					
						commit
						7344285c19
					
				
					 9 changed files with 140 additions and 113 deletions
				
			
		|  | @ -2509,9 +2509,10 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) | |||
|             DISPATCH(); | ||||
|         } | ||||
| 
 | ||||
|         TARGET(BUILD_TUPLE_UNPACK_WITH_CALL) | ||||
|         TARGET(BUILD_TUPLE_UNPACK) | ||||
|         TARGET(BUILD_LIST_UNPACK) { | ||||
|             int convert_to_tuple = opcode == BUILD_TUPLE_UNPACK; | ||||
|             int convert_to_tuple = opcode != BUILD_LIST_UNPACK; | ||||
|             Py_ssize_t i; | ||||
|             PyObject *sum = PyList_New(0); | ||||
|             PyObject *return_value; | ||||
|  | @ -2524,6 +2525,16 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) | |||
| 
 | ||||
|                 none_val = _PyList_Extend((PyListObject *)sum, PEEK(i)); | ||||
|                 if (none_val == NULL) { | ||||
|                     if (opcode == BUILD_TUPLE_UNPACK_WITH_CALL && | ||||
|                         PyErr_ExceptionMatches(PyExc_TypeError)) { | ||||
|                         PyObject *func = PEEK(1 + oparg); | ||||
|                         PyErr_Format(PyExc_TypeError, | ||||
|                                 "%.200s%.200s argument after * " | ||||
|                                 "must be an iterable, not %.200s", | ||||
|                                 PyEval_GetFuncName(func), | ||||
|                                 PyEval_GetFuncDesc(func), | ||||
|                                 PEEK(i)->ob_type->tp_name); | ||||
|                     } | ||||
|                     Py_DECREF(sum); | ||||
|                     goto error; | ||||
|                 } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka