mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Add tests for r84209 (crashes in the Ast builder)
Also remove one tab, and move a check closer to the possible failure.
This commit is contained in:
		
							parent
							
								
									8101021eae
								
							
						
					
					
						commit
						12844e6df6
					
				
					 2 changed files with 31 additions and 3 deletions
				
			
		|  | @ -484,6 +484,34 @@ | |||
| Traceback (most recent call last): | ||||
| SyntaxError: can't assign to literal | ||||
| 
 | ||||
| Corner-cases that used to fail to raise the correct error: | ||||
| 
 | ||||
|     >>> def f(*, x=lambda __debug__:0): pass | ||||
|     Traceback (most recent call last): | ||||
|     SyntaxError: assignment to keyword | ||||
| 
 | ||||
|     >>> def f(*args:(lambda __debug__:0)): pass | ||||
|     Traceback (most recent call last): | ||||
|     SyntaxError: assignment to keyword | ||||
| 
 | ||||
|     >>> def f(**kwargs:(lambda __debug__:0)): pass | ||||
|     Traceback (most recent call last): | ||||
|     SyntaxError: assignment to keyword | ||||
| 
 | ||||
|     >>> with (lambda *:0): pass | ||||
|     Traceback (most recent call last): | ||||
|     SyntaxError: named arguments must follow bare * | ||||
| 
 | ||||
| Corner-cases that used to crash: | ||||
| 
 | ||||
|     >>> def f(**__debug__): pass | ||||
|     Traceback (most recent call last): | ||||
|     SyntaxError: assignment to keyword | ||||
| 
 | ||||
|     >>> def f(*xx, __debug__): pass | ||||
|     Traceback (most recent call last): | ||||
|     SyntaxError: assignment to keyword | ||||
| 
 | ||||
| """ | ||||
| 
 | ||||
| import re | ||||
|  |  | |||
|  | @ -689,7 +689,7 @@ handle_keywordonly_args(struct compiling *c, const node *n, int start, | |||
|                 if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) { | ||||
|                     expression = ast_for_expr(c, CHILD(n, i + 2)); | ||||
|                     if (!expression) | ||||
| 		      goto error; | ||||
|                         goto error; | ||||
|                     asdl_seq_SET(kwdefaults, j, expression); | ||||
|                     i += 2; /* '=' and test */ | ||||
|                 } | ||||
|  | @ -892,14 +892,14 @@ ast_for_arguments(struct compiling *c, const node *n) | |||
|                 ch = CHILD(n, i+1);  /* tfpdef */ | ||||
|                 assert(TYPE(ch) == tfpdef || TYPE(ch) == vfpdef); | ||||
|                 kwarg = NEW_IDENTIFIER(CHILD(ch, 0)); | ||||
|                 if (!kwarg) | ||||
|                     return NULL; | ||||
|                 if (NCH(ch) > 1) { | ||||
|                     /* there is an annotation on the kwarg */ | ||||
|                     kwargannotation = ast_for_expr(c, CHILD(ch, 2)); | ||||
|                     if (!kwargannotation) | ||||
|                         return NULL; | ||||
|                 } | ||||
|                 if (!kwarg) | ||||
|                     return NULL; | ||||
|                 if (forbidden_name(kwarg, CHILD(ch, 0), 0)) | ||||
|                     return NULL; | ||||
|                 i += 3; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Amaury Forgeot d'Arc
						Amaury Forgeot d'Arc