mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Issue #28076: Variable annotations should be mangled for private names.
By Ivan Levkivskyi.
This commit is contained in:
		
							parent
							
								
									a6d75fdc37
								
							
						
					
					
						commit
						015d874626
					
				
					 3 changed files with 13 additions and 6 deletions
				
			
		|  | @ -4562,6 +4562,7 @@ static int | |||
| compiler_annassign(struct compiler *c, stmt_ty s) | ||||
| { | ||||
|     expr_ty targ = s->v.AnnAssign.target; | ||||
|     PyObject* mangled; | ||||
| 
 | ||||
|     assert(s->kind == AnnAssign_kind); | ||||
| 
 | ||||
|  | @ -4576,8 +4577,13 @@ compiler_annassign(struct compiler *c, stmt_ty s) | |||
|         if (s->v.AnnAssign.simple && | ||||
|             (c->u->u_scope_type == COMPILER_SCOPE_MODULE || | ||||
|              c->u->u_scope_type == COMPILER_SCOPE_CLASS)) { | ||||
|             mangled = _Py_Mangle(c->u->u_private, targ->v.Name.id); | ||||
|             if (!mangled) { | ||||
|                 return 0; | ||||
|             } | ||||
|             VISIT(c, expr, s->v.AnnAssign.annotation); | ||||
|             ADDOP_O(c, STORE_ANNOTATION, targ->v.Name.id, names) | ||||
|             /* ADDOP_N decrefs its argument */ | ||||
|             ADDOP_N(c, STORE_ANNOTATION, mangled, names); | ||||
|         } | ||||
|         break; | ||||
|     case Attribute_kind: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum