@@ -5,6 +5,7 @@ use crate::frame::FrameRef;
55use crate :: function:: { OptionalArg , PyFuncArgs } ;
66use crate :: obj:: objstr:: PyStringRef ;
77use crate :: pyobject:: { IntoPyObject , ItemProtocol , PyClassImpl , PyContext , PyObjectRef , PyResult } ;
8+ use crate :: version;
89use crate :: vm:: VirtualMachine ;
910
1011/*
@@ -160,6 +161,8 @@ pub fn make_module(vm: &VirtualMachine, module: PyObjectRef, builtins: PyObjectR
160161 "unknown" . to_string ( )
161162 } ;
162163
164+ let copyright = "Copyright (c) 2019 RustPython Team" ;
165+
163166 let sys_doc = "This module provides access to some objects used or maintained by the
164167interpreter and to functions that interact strongly with the interpreter.
165168
@@ -229,16 +232,23 @@ setprofile() -- set the global profiling function
229232setrecursionlimit() -- set the max recursion depth for the interpreter
230233settrace() -- set the global debug tracing function
231234" ;
232- let mut module_names: Vec < _ > = vm. stdlib_inits . borrow ( ) . keys ( ) . cloned ( ) . collect ( ) ;
235+ let mut module_names: Vec < String > = vm. stdlib_inits . borrow ( ) . keys ( ) . cloned ( ) . collect ( ) ;
233236 module_names. push ( "sys" . to_string ( ) ) ;
234237 module_names. push ( "builtins" . to_string ( ) ) ;
235238 module_names. sort ( ) ;
239+ let builtin_module_names = ctx. new_tuple (
240+ module_names
241+ . iter ( )
242+ . map ( |v| v. into_pyobject ( vm) . unwrap ( ) )
243+ . collect ( ) ,
244+ ) ;
236245 let modules = ctx. new_dict ( ) ;
237246 extend_module ! ( vm, module, {
238247 "__name__" => ctx. new_str( String :: from( "sys" ) ) ,
239248 "argv" => argv( ctx) ,
240- "builtin_module_names" => ctx . new_tuple ( module_names . iter ( ) . map ( |v| v . into_pyobject ( vm ) . unwrap ( ) ) . collect ( ) ) ,
249+ "builtin_module_names" => builtin_module_names ,
241250 "byteorder" => ctx. new_str( bytorder) ,
251+ "copyright" => ctx. new_str( copyright. to_string( ) ) ,
242252 "flags" => flags,
243253 "getrefcount" => ctx. new_rustfunc( sys_getrefcount) ,
244254 "getsizeof" => ctx. new_rustfunc( sys_getsizeof) ,
@@ -260,6 +270,7 @@ settrace() -- set the global debug tracing function
260270 "path_importer_cache" => ctx. new_dict( ) ,
261271 "pycache_prefix" => vm. get_none( ) ,
262272 "dont_write_bytecode" => vm. new_bool( true ) ,
273+ "version" => vm. new_str( version:: get_version( ) ) ,
263274 } ) ;
264275
265276 modules. set_item ( "sys" , module. clone ( ) , vm) . unwrap ( ) ;
0 commit comments