mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Issue #1573, second attempt:
"def f(*, **kw)" now raises a SyntaxError.
This commit is contained in:
		
							parent
							
								
									3279b5df3c
								
							
						
					
					
						commit
						40d3a67a19
					
				
					 3 changed files with 9 additions and 13 deletions
				
			
		
							
								
								
									
										11
									
								
								Python/ast.c
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								Python/ast.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -649,8 +649,12 @@ handle_keywordonly_args(struct compiling *c, const node *n, int start,
 | 
			
		|||
    arg_ty arg;
 | 
			
		||||
    int i = start;
 | 
			
		||||
    int j = 0; /* index for kwdefaults and kwonlyargs */
 | 
			
		||||
    assert((kwonlyargs != NULL && kwdefaults != NULL) ||
 | 
			
		||||
           TYPE(CHILD(n, i)) == DOUBLESTAR);
 | 
			
		||||
 | 
			
		||||
    if (kwonlyargs == NULL) {
 | 
			
		||||
        ast_error(CHILD(n, start), "named arguments must follow bare *");
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
    assert(kwdefaults != NULL);
 | 
			
		||||
    while (i < NCH(n)) {
 | 
			
		||||
        ch = CHILD(n, i);
 | 
			
		||||
        switch (TYPE(ch)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -814,7 +818,8 @@ ast_for_arguments(struct compiling *c, const node *n)
 | 
			
		|||
                break;
 | 
			
		||||
            case STAR:
 | 
			
		||||
                if (i+1 >= NCH(n)) {
 | 
			
		||||
                    ast_error(CHILD(n, i), "no name for vararg");
 | 
			
		||||
                    ast_error(CHILD(n, i), 
 | 
			
		||||
                        "named arguments must follow bare *");
 | 
			
		||||
                    goto error;
 | 
			
		||||
                }
 | 
			
		||||
                ch = CHILD(n, i+1);  /* tfpdef or COMMA */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue