1616from  asyncio  import  log 
1717from  asyncio  import  protocols 
1818from  asyncio  import  sslproto 
19- from  asyncio  import  selector_events 
2019from  test .test_asyncio  import  utils  as  test_utils 
2120from  test .test_asyncio  import  functional  as  func_tests 
2221
@@ -111,12 +110,14 @@ def test_connection_lost(self):
111110        self .assertIsInstance (waiter .exception (), ConnectionAbortedError )
112111
113112    def  test_connection_lost_when_busy (self ):
113+         # gh-118950: SSLProtocol.connection_lost not being called when OSError 
114+         # is thrown on asyncio.write. 
114115        sock  =  mock .Mock ()
115116        sock .fileno  =  mock .Mock (return_value = 12345 )
116117        sock .send  =  mock .Mock (side_effect = BrokenPipeError )
117118
118-         # construct StreamWriter chain that contains loop dependant logic this emulates that  
119-         # _make_ssl_transport() does in BaseSelectorEventLoop 
119+         # construct StreamWriter chain that contains loop dependant logic this emulates 
120+         # what  _make_ssl_transport() does in BaseSelectorEventLoop 
120121        reader  =  asyncio .StreamReader (limit = 2  **  16 , loop = self .loop )
121122        protocol  =  asyncio .StreamReaderProtocol (reader , loop = self .loop )
122123        ssl_proto  =  self .ssl_protocol (proto = protocol )
@@ -136,7 +137,8 @@ def test_connection_lost_when_busy(self):
136137        ssl_proto ._outgoing  =  outgoing 
137138
138139        # use correct socket transport to initialize the SSLProtocol 
139-         selector_events ._SelectorSocketTransport (self .loop , sock , ssl_proto )
140+         self .loop ._make_socket_transport (sock , ssl_proto )
141+ 
140142        transport  =  ssl_proto ._app_transport 
141143        writer  =  asyncio .StreamWriter (transport , protocol , reader , self .loop )
142144
0 commit comments