mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Jiwon Seo's PEP 3102 implementation.
See SF#1549670. The compiler package has not yet been updated.
This commit is contained in:
		
							parent
							
								
									fc2a0a8e3c
								
							
						
					
					
						commit
						4f72a78684
					
				
					 31 changed files with 739 additions and 227 deletions
				
			
		|  | @ -893,6 +893,17 @@ symtable_add_def(struct symtable *st, PyObject *name, int flag) | |||
| 	} \ | ||||
| } | ||||
| 
 | ||||
| #define VISIT_KWONLYDEFAULTS(ST, KW_DEFAULTS) { \ | ||||
| 	int i = 0; \ | ||||
| 	asdl_seq *seq = (KW_DEFAULTS); /* avoid variable capture */ \ | ||||
| 	for (i = 0; i < asdl_seq_LEN(seq); i++) { \ | ||||
| 		expr_ty elt = (expr_ty)asdl_seq_GET(seq, i); \ | ||||
| 		if (!elt) continue; /* can be NULL */ \ | ||||
| 		if (!symtable_visit_expr((ST), elt)) \ | ||||
| 			return 0; \ | ||||
| 	} \ | ||||
| } | ||||
| 
 | ||||
| static int | ||||
| symtable_new_tmpname(struct symtable *st) | ||||
| { | ||||
|  | @ -910,6 +921,8 @@ symtable_new_tmpname(struct symtable *st) | |||
| 	return 1; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| static int | ||||
| symtable_visit_stmt(struct symtable *st, stmt_ty s) | ||||
| { | ||||
|  | @ -919,6 +932,9 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) | |||
| 			return 0; | ||||
| 		if (s->v.FunctionDef.args->defaults) | ||||
| 			VISIT_SEQ(st, expr, s->v.FunctionDef.args->defaults); | ||||
| 		if (s->v.FunctionDef.args->kw_defaults) | ||||
| 			VISIT_KWONLYDEFAULTS(st,  | ||||
| 					   s->v.FunctionDef.args->kw_defaults); | ||||
| 		if (s->v.FunctionDef.decorators) | ||||
| 			VISIT_SEQ(st, expr, s->v.FunctionDef.decorators); | ||||
| 		if (!symtable_enter_block(st, s->v.FunctionDef.name,  | ||||
|  | @ -1262,6 +1278,8 @@ symtable_visit_arguments(struct symtable *st, arguments_ty a) | |||
| 	*/ | ||||
| 	if (a->args && !symtable_visit_params(st, a->args, 1)) | ||||
| 		return 0; | ||||
| 	if (a->kwonlyargs && !symtable_visit_params(st, a->kwonlyargs, 1)) | ||||
| 		return 0; | ||||
| 	if (a->vararg) { | ||||
| 		if (!symtable_add_def(st, a->vararg, DEF_PARAM)) | ||||
| 			return 0; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum