mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Implement MvL's improvement on __context__ in Condition;
this can just call __context__ on the underlying lock. (The same change for Semaphore does *not* work!)
This commit is contained in:
		
							parent
							
								
									4e1777de63
								
							
						
					
					
						commit
						8f56d02309
					
				
					 1 changed files with 1 additions and 5 deletions
				
			
		|  | @ -164,7 +164,6 @@ def __init__(self, lock=None, verbose=None): | ||||||
|         self.__lock = lock |         self.__lock = lock | ||||||
|         # Export the lock's acquire() and release() methods |         # Export the lock's acquire() and release() methods | ||||||
|         self.acquire = lock.acquire |         self.acquire = lock.acquire | ||||||
|         self.__enter__ = self.acquire |  | ||||||
|         self.release = lock.release |         self.release = lock.release | ||||||
|         # If the lock defines _release_save() and/or _acquire_restore(), |         # If the lock defines _release_save() and/or _acquire_restore(), | ||||||
|         # these override the default implementations (which just call |         # these override the default implementations (which just call | ||||||
|  | @ -184,10 +183,7 @@ def __init__(self, lock=None, verbose=None): | ||||||
|         self.__waiters = [] |         self.__waiters = [] | ||||||
| 
 | 
 | ||||||
|     def __context__(self): |     def __context__(self): | ||||||
|         return self |         return self.__lock.__context__() | ||||||
| 
 |  | ||||||
|     def __exit__(self, t, v, tb): |  | ||||||
|         self.release() |  | ||||||
| 
 | 
 | ||||||
|     def __repr__(self): |     def __repr__(self): | ||||||
|         return "<Condition(%s, %d)>" % (self.__lock, len(self.__waiters)) |         return "<Condition(%s, %d)>" % (self.__lock, len(self.__waiters)) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum