Set MAX_WHILE_ITERATIONS as module variable (#520)
This commit is contained in:
		
							parent
							
								
									c4bd41d39c
								
							
						
					
					
						commit
						8965b6a573
					
				|  | @ -52,6 +52,7 @@ ERRORS = { | |||
| 
 | ||||
| DEFAULT_MAX_LEN_OUTPUT = 50000 | ||||
| MAX_OPERATIONS = 10000000 | ||||
| MAX_WHILE_ITERATIONS = 1000000 | ||||
| 
 | ||||
| 
 | ||||
| def custom_print(*args): | ||||
|  | @ -241,7 +242,6 @@ def evaluate_while( | |||
|     custom_tools: Dict[str, Callable], | ||||
|     authorized_imports: List[str], | ||||
| ) -> None: | ||||
|     max_iterations = 1000000 | ||||
|     iterations = 0 | ||||
|     while evaluate_ast(while_loop.test, state, static_tools, custom_tools, authorized_imports): | ||||
|         for node in while_loop.body: | ||||
|  | @ -252,8 +252,8 @@ def evaluate_while( | |||
|             except ContinueException: | ||||
|                 break | ||||
|         iterations += 1 | ||||
|         if iterations > max_iterations: | ||||
|             raise InterpreterError(f"Maximum number of {max_iterations} iterations in While loop exceeded") | ||||
|         if iterations > MAX_WHILE_ITERATIONS: | ||||
|             raise InterpreterError(f"Maximum number of {MAX_WHILE_ITERATIONS} iterations in While loop exceeded") | ||||
|     return None | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue