@@ -4,7 +4,7 @@ use std::{env, mem};
4
4
use crate :: frame:: FrameRef ;
5
5
use crate :: function:: { OptionalArg , PyFuncArgs } ;
6
6
use crate :: obj:: objstr:: PyStringRef ;
7
- use crate :: pyobject:: { ItemProtocol , PyContext , PyObjectRef , PyResult } ;
7
+ use crate :: pyobject:: { IntoPyObject , ItemProtocol , PyContext , PyObjectRef , PyResult } ;
8
8
use crate :: vm:: VirtualMachine ;
9
9
10
10
/*
@@ -144,9 +144,14 @@ setprofile() -- set the global profiling function
144
144
setrecursionlimit() -- set the max recursion depth for the interpreter
145
145
settrace() -- set the global debug tracing function
146
146
" ;
147
+ let mut module_names: Vec < _ > = vm. stdlib_inits . borrow ( ) . keys ( ) . cloned ( ) . collect ( ) ;
148
+ module_names. push ( "sys" . to_string ( ) ) ;
149
+ module_names. push ( "builtins" . to_string ( ) ) ;
150
+ module_names. sort ( ) ;
147
151
let modules = ctx. new_dict ( ) ;
148
152
extend_module ! ( vm, module, {
149
153
"argv" => argv( ctx) ,
154
+ "builtin_module_names" => ctx. new_tuple( module_names. iter( ) . map( |v| v. into_pyobject( vm) . unwrap( ) ) . collect( ) ) ,
150
155
"getrefcount" => ctx. new_rustfunc( sys_getrefcount) ,
151
156
"getsizeof" => ctx. new_rustfunc( sys_getsizeof) ,
152
157
"intern" => ctx. new_rustfunc( sys_intern) ,
0 commit comments