mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	asyncio: sync with Tulip
- CoroWrapper.__del__() now reuses repr(CoroWrapper) to log the "... was never yielded from" warning - Improve CoroWrapper: copy also the qualified name on Python 3.4, not only on Python 3.5+
This commit is contained in:
		
							parent
							
								
									c39ba7d611
								
							
						
					
					
						commit
						737c34fa85
					
				
					 3 changed files with 6 additions and 18 deletions
				
			
		|  | @ -29,8 +29,6 @@ | |||
| _DEBUG = (not sys.flags.ignore_environment | ||||
|           and bool(os.environ.get('PYTHONASYNCIODEBUG'))) | ||||
| 
 | ||||
| _PY35 = (sys.version_info >= (3, 5)) | ||||
| 
 | ||||
| 
 | ||||
| # Check for CPython issue #21209 | ||||
| def has_yield_from_bug(): | ||||
|  | @ -119,8 +117,7 @@ def __del__(self): | |||
|         gen = getattr(self, 'gen', None) | ||||
|         frame = getattr(gen, 'gi_frame', None) | ||||
|         if frame is not None and frame.f_lasti == -1: | ||||
|             func = events._format_callback(self.func, ()) | ||||
|             msg = 'Coroutine %s was never yielded from' % func | ||||
|             msg = '%r was never yielded from' % self | ||||
|             tb = getattr(self, '_source_traceback', ()) | ||||
|             if tb: | ||||
|                 tb = ''.join(traceback.format_list(tb)) | ||||
|  | @ -155,7 +152,7 @@ def wrapper(*args, **kwds): | |||
|             if w._source_traceback: | ||||
|                 del w._source_traceback[-1] | ||||
|             w.__name__ = func.__name__ | ||||
|             if _PY35: | ||||
|             if hasattr(func, '__qualname__'): | ||||
|                 w.__qualname__ = func.__qualname__ | ||||
|             w.__doc__ = func.__doc__ | ||||
|             return w | ||||
|  | @ -178,10 +175,7 @@ def iscoroutine(obj): | |||
| 
 | ||||
| def _format_coroutine(coro): | ||||
|     assert iscoroutine(coro) | ||||
|     if _PY35: | ||||
|         coro_name = coro.__qualname__ | ||||
|     else: | ||||
|         coro_name = coro.__name__ | ||||
|     coro_name = getattr(coro, '__qualname__', coro.__name__) | ||||
| 
 | ||||
|     filename = coro.gi_code.co_filename | ||||
|     if (isinstance(coro, CoroWrapper) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Victor Stinner
						Victor Stinner