mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	gh-107409: set __wrapped__ attribute in reprlib.recursive_repr (#107410)
				
					
				
			Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
		
							parent
							
								
									0f2fb6efb4
								
							
						
					
					
						commit
						4845b9712f
					
				
					 3 changed files with 11 additions and 0 deletions
				
			
		|  | @ -29,6 +29,7 @@ def wrapper(self): | |||
|         wrapper.__name__ = getattr(user_function, '__name__') | ||||
|         wrapper.__qualname__ = getattr(user_function, '__qualname__') | ||||
|         wrapper.__annotations__ = getattr(user_function, '__annotations__', {}) | ||||
|         wrapper.__wrapped__ = user_function | ||||
|         return wrapper | ||||
| 
 | ||||
|     return decorating_function | ||||
|  |  | |||
|  | @ -765,5 +765,14 @@ def test_assigned_attributes(self): | |||
|         for name in assigned: | ||||
|             self.assertIs(getattr(wrapper, name), getattr(wrapped, name)) | ||||
| 
 | ||||
|     def test__wrapped__(self): | ||||
|         class X: | ||||
|             def __repr__(self): | ||||
|                 return 'X()' | ||||
|             f = __repr__ # save reference to check it later | ||||
|             __repr__ = recursive_repr()(__repr__) | ||||
| 
 | ||||
|         self.assertIs(X.f, X.__repr__.__wrapped__) | ||||
| 
 | ||||
| if __name__ == "__main__": | ||||
|     unittest.main() | ||||
|  |  | |||
|  | @ -0,0 +1 @@ | |||
| Set :attr:`!__wrapped__` attribute in :func:`reprlib.recursive_repr`. | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 denballakh
						denballakh