mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	bpo-31647: Fix write_eof() after close() for SelectorSocketTransport (GH-7149)
Fixed bug where calling write_eof() on a _SelectorSocketTransport after it's already closed raises AttributeError.
This commit is contained in:
		
							parent
							
								
									35230d08e0
								
							
						
					
					
						commit
						23f587e395
					
				
					 3 changed files with 9 additions and 1 deletions
				
			
		|  | @ -899,7 +899,7 @@ def _write_ready(self): | |||
|                     self._sock.shutdown(socket.SHUT_WR) | ||||
| 
 | ||||
|     def write_eof(self): | ||||
|         if self._eof: | ||||
|         if self._closing or self._eof: | ||||
|             return | ||||
|         self._eof = True | ||||
|         if not self._buffer: | ||||
|  |  | |||
|  | @ -1263,6 +1263,12 @@ def test_write_eof_buffer(self): | |||
|         self.sock.shutdown.assert_called_with(socket.SHUT_WR) | ||||
|         tr.close() | ||||
| 
 | ||||
|     def test_write_eof_after_close(self): | ||||
|         tr = self.socket_transport() | ||||
|         tr.close() | ||||
|         self.loop.run_until_complete(asyncio.sleep(0)) | ||||
|         tr.write_eof() | ||||
| 
 | ||||
|     @mock.patch('asyncio.base_events.logger') | ||||
|     def test_transport_close_remove_writer(self, m_log): | ||||
|         remove_writer = self.loop._remove_writer = mock.Mock() | ||||
|  |  | |||
|  | @ -0,0 +1,2 @@ | |||
| Fixed bug where calling write_eof() on a _SelectorSocketTransport after it's | ||||
| already closed raises AttributeError. | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 twisteroid ambassador
						twisteroid ambassador