mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	Issue 2117. Update compiler module to handle class decorators.
Thanks Thomas Herve
This commit is contained in:
		
							parent
							
								
									a3c8c10201
								
							
						
					
					
						commit
						4219da4bd0
					
				
					 4 changed files with 21 additions and 4 deletions
				
			
		|  | @ -232,6 +232,18 @@ def decorators(self, nodelist): | |||
|             items.append(self.decorator(dec_nodelist[1:])) | ||||
|         return Decorators(items) | ||||
| 
 | ||||
|     def decorated(self, nodelist): | ||||
|         assert nodelist[0][0] == symbol.decorators | ||||
|         if nodelist[1][0] == symbol.funcdef: | ||||
|             n = [nodelist[0]] + list(nodelist[1][1:]) | ||||
|             return self.funcdef(n) | ||||
|         elif nodelist[1][0] == symbol.classdef: | ||||
|             decorators = self.decorators(nodelist[0][1:]) | ||||
|             cls = self.classdef(nodelist[1][1:]) | ||||
|             cls.decorators = decorators | ||||
|             return cls | ||||
|         raise WalkerError() | ||||
| 
 | ||||
|     def funcdef(self, nodelist): | ||||
|         #                    -6   -5    -4         -3  -2    -1 | ||||
|         # funcdef: [decorators] 'def' NAME parameters ':' suite | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Facundo Batista
						Facundo Batista