mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	GH-131798: Narrow the return type of _GET_LEN to int (GH-133345)
This commit is contained in:
		
							parent
							
								
									e4fbfb1288
								
							
						
					
					
						commit
						e1c0c451a2
					
				
					 4 changed files with 87 additions and 1 deletions
				
			
		
							
								
								
									
										23
									
								
								Python/optimizer_cases.c.h
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										23
									
								
								Python/optimizer_cases.c.h
									
										
									
										generated
									
									
									
								
							|  | @ -1463,8 +1463,29 @@ | |||
|         } | ||||
| 
 | ||||
|         case _GET_LEN: { | ||||
|             JitOptSymbol *obj; | ||||
|             JitOptSymbol *len; | ||||
|             len = sym_new_not_null(ctx); | ||||
|             obj = stack_pointer[-1]; | ||||
|             int tuple_length = sym_tuple_length(obj); | ||||
|             if (tuple_length == -1) { | ||||
|                 len = sym_new_type(ctx, &PyLong_Type); | ||||
|             } | ||||
|             else { | ||||
|                 assert(tuple_length >= 0); | ||||
|                 PyObject *temp = PyLong_FromLong(tuple_length); | ||||
|                 if (temp == NULL) { | ||||
|                     goto error; | ||||
|                 } | ||||
|                 if (_Py_IsImmortal(temp)) { | ||||
|                     REPLACE_OP(this_instr, _LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)temp); | ||||
|                 } | ||||
|                 len = sym_new_const(ctx, temp); | ||||
|                 stack_pointer[0] = len; | ||||
|                 stack_pointer += 1; | ||||
|                 assert(WITHIN_STACK_BOUNDS()); | ||||
|                 Py_DECREF(temp); | ||||
|                 stack_pointer += -1; | ||||
|             } | ||||
|             stack_pointer[0] = len; | ||||
|             stack_pointer += 1; | ||||
|             assert(WITHIN_STACK_BOUNDS()); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nadeshiko Manju
						Nadeshiko Manju