@@ -30,7 +30,7 @@ mod _ssl {
3030 } ,
3131 socket:: { self , PySocket } ,
3232 vm:: {
33- builtins:: { PyBaseException , PyBaseExceptionRef , PyStrRef , PyType , PyTypeRef , PyWeak } ,
33+ builtins:: { PyBaseExceptionRef , PyStrRef , PyType , PyTypeRef , PyWeak } ,
3434 exceptions,
3535 function:: {
3636 ArgBytesLike , ArgCallable , ArgMemoryBuffer , ArgStrOrBytesLike , IntoPyException ,
@@ -39,7 +39,7 @@ mod _ssl {
3939 stdlib:: os:: PyPathLike ,
4040 types:: Constructor ,
4141 utils:: { Either , ToCString } ,
42- ItemProtocol , PyClassImpl , PyObjectRef , PyRef , PyResult , PyValue , VirtualMachine ,
42+ ItemProtocol , PyObjectRef , PyRef , PyResult , PyValue , VirtualMachine ,
4343 } ,
4444 } ;
4545 use crossbeam_utils:: atomic:: AtomicCell ;
@@ -177,45 +177,49 @@ mod _ssl {
177177 /// An error occurred in the SSL implementation.
178178 #[ pyattr( name = "SSLError" , once) ]
179179 fn ssl_error ( vm : & VirtualMachine ) -> PyTypeRef {
180- PyType :: new_simple_ref ( "ssl.SSLError" , & vm. ctx . exceptions . os_error ) . unwrap ( )
180+ vm. ctx . new_exception_type (
181+ "ssl" ,
182+ "SSLError" ,
183+ Some ( vec ! [ vm. ctx. exceptions. os_error. clone( ) ] ) ,
184+ )
181185 }
182186
183187 /// A certificate could not be verified.
184188 #[ pyattr( name = "SSLCertVerificationError" , once) ]
185189 fn ssl_cert_verification_error ( vm : & VirtualMachine ) -> PyTypeRef {
186- let ssl_error = ssl_error ( vm) ;
187- PyType :: new_ref (
188- "ssl.SSLCertVerificationError" ,
189- vec ! [ ssl_error, vm. ctx. exceptions. value_error. clone( ) ] ,
190- Default :: default ( ) ,
191- PyBaseException :: make_slots ( ) ,
192- vm. ctx . types . type_type . clone ( ) ,
190+ vm. ctx . new_exception_type (
191+ "ssl" ,
192+ "SSLCertVerificationError" ,
193+ Some ( vec ! [ ssl_error( vm) , vm. ctx. exceptions. value_error. clone( ) ] ) ,
193194 )
194- . unwrap ( )
195195 }
196196
197197 /// SSL/TLS session closed cleanly.
198198 #[ pyattr( name = "SSLZeroReturnError" , once) ]
199199 fn ssl_zero_return_error ( vm : & VirtualMachine ) -> PyTypeRef {
200- PyType :: new_simple_ref ( "ssl.SSLZeroReturnError" , & ssl_error ( vm) ) . unwrap ( )
200+ vm. ctx
201+ . new_exception_type ( "ssl" , "SSLZeroReturnError" , Some ( vec ! [ ssl_error( vm) ] ) )
201202 }
202203
203204 /// Non-blocking SSL socket needs to read more data before the requested operation can be completed.
204205 #[ pyattr( name = "SSLWantReadError" , once) ]
205206 fn ssl_want_read_error ( vm : & VirtualMachine ) -> PyTypeRef {
206- PyType :: new_simple_ref ( "ssl.SSLWantReadError" , & ssl_error ( vm) ) . unwrap ( )
207+ vm. ctx
208+ . new_exception_type ( "ssl" , "SSLWantReadError" , Some ( vec ! [ ssl_error( vm) ] ) )
207209 }
208210
209211 /// Non-blocking SSL socket needs to write more data before the requested operation can be completed.
210212 #[ pyattr( name = "SSLWantWriteError" , once) ]
211213 fn ssl_want_write_error ( vm : & VirtualMachine ) -> PyTypeRef {
212- PyType :: new_simple_ref ( "ssl.SSLWantWriteError" , & ssl_error ( vm) ) . unwrap ( )
214+ vm. ctx
215+ . new_exception_type ( "ssl" , "SSLWantWriteError" , Some ( vec ! [ ssl_error( vm) ] ) )
213216 }
214217
215218 /// System error when attempting SSL operation.
216219 #[ pyattr( name = "SSLSyscallError" , once) ]
217220 fn ssl_syscall_error ( vm : & VirtualMachine ) -> PyTypeRef {
218- PyType :: new_simple_ref ( "ssl.SSLSyscallError" , & ssl_error ( vm) ) . unwrap ( )
221+ vm. ctx
222+ . new_exception_type ( "ssl" , "SSLSyscallError" , Some ( vec ! [ ssl_error( vm) ] ) )
219223 }
220224
221225 /// SSL/TLS connection terminated abruptly.
0 commit comments