mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	bpo-46827: pass sock.type to getaddrinfo in sock_connect (GH-31499)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
(cherry picked from commit 8fb94893e4)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
			
			
This commit is contained in:
		
							parent
							
								
									2387aeacc7
								
							
						
					
					
						commit
						29e8c43b32
					
				
					 3 changed files with 22 additions and 1 deletions
				
			
		|  | @ -189,6 +189,24 @@ def test_write_to_self_exception(self): | |||
|         self.loop._csock.send.side_effect = RuntimeError() | ||||
|         self.assertRaises(RuntimeError, self.loop._write_to_self) | ||||
| 
 | ||||
|     @mock.patch('socket.getaddrinfo') | ||||
|     def test_sock_connect_resolve_using_socket_params(self, m_gai): | ||||
|         addr = ('need-resolution.com', 8080) | ||||
|         for sock_type in [socket.SOCK_STREAM, socket.SOCK_DGRAM]: | ||||
|             with self.subTest(sock_type): | ||||
|                 sock = test_utils.mock_nonblocking_socket(type=sock_type) | ||||
| 
 | ||||
|                 m_gai.side_effect = \ | ||||
|                     lambda *args: [(None, None, None, None, ('127.0.0.1', 0))] | ||||
| 
 | ||||
|                 con = self.loop.create_task(self.loop.sock_connect(sock, addr)) | ||||
|                 self.loop.run_until_complete(con) | ||||
|                 m_gai.assert_called_with( | ||||
|                     addr[0], addr[1], sock.family, sock.type, sock.proto, 0) | ||||
| 
 | ||||
|                 self.loop.run_until_complete(con) | ||||
|                 sock.connect.assert_called_with(('127.0.0.1', 0)) | ||||
| 
 | ||||
|     def test_add_reader(self): | ||||
|         self.loop._selector.get_key.side_effect = KeyError | ||||
|         cb = lambda: True | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)