@@ -4,7 +4,6 @@ use crate::pystate::ensure_thread_has_vm_attached;
44use alloc:: ffi:: CString ;
55use core:: ffi:: { c_char, c_int, c_ulong} ;
66use core:: sync:: atomic:: { AtomicPtr , Ordering } ;
7- use rustpython_vm:: common:: rc:: PyRc ;
87use rustpython_vm:: stdlib:: sys;
98use rustpython_vm:: version:: { MAJOR , MICRO , MINOR , RUSTPYTHON_BUILD_INFO , VERSION_HEX } ;
109use rustpython_vm:: vm:: thread:: ThreadedVirtualMachine ;
@@ -19,7 +18,7 @@ pub(crate) fn request_vm_from_interpreter() -> ThreadedVirtualMachine {
1918 get_main_interpreter ( )
2019 . as_ref ( )
2120 . expect ( "Interpreter not initialized" )
22- . enter ( |vm| vm . new_thread ( ) )
21+ . new_thread ( )
2322}
2423
2524#[ unsafe( no_mangle) ]
@@ -40,20 +39,21 @@ pub extern "C" fn Py_InitializeEx(_initsigs: c_int) {
4039 let mut interp = get_main_interpreter ( ) ;
4140 if interp. is_none ( ) {
4241 // Safety: Interpreter was not initialized before, so we can safely assume the statics are not used
43- unsafe { init_exception_statics ( & Context :: genesis ( ) . exceptions ) } ;
42+ unsafe { init_exception_statics ( & Context :: genesis_unchecked ( ) . exceptions ) } ;
4443 let builder = Interpreter :: builder ( Default :: default ( ) ) ;
45- let defs = rustpython_stdlib:: stdlib_module_defs ( & builder. ctx ) ;
46- * interp = builder
47- . add_native_modules ( & defs)
48- . init_hook ( |vm| {
49- let state = PyRc :: get_mut ( & mut vm. state ) . unwrap ( ) ;
50- let path = rustpython_pylib:: LIB_PATH . to_owned ( ) ;
51-
52- state. config . paths . stdlib_dir = Some ( path. clone ( ) ) ;
53- state. config . paths . module_search_paths . insert ( 0 , path) ;
54- } )
55- . build ( )
56- . into ( ) ;
44+ let defs = rustpython_stdlib:: stdlib_module_defs ( unsafe { builder. context ( ) } ) ;
45+ * interp = unsafe {
46+ builder
47+ . add_native_modules ( & defs)
48+ . configure ( |config| {
49+ let path = rustpython_pylib:: LIB_PATH . to_owned ( ) ;
50+
51+ config. paths . stdlib_dir = Some ( path. clone ( ) ) ;
52+ config. paths . module_search_paths . insert ( 0 , path) ;
53+ } )
54+ . build ( )
55+ . into ( )
56+ } ;
5757 MAIN_INTERP_PTR . store (
5858 interp. as_ref ( ) . unwrap ( ) as * const _ as * mut _ ,
5959 Ordering :: Release ,
0 commit comments