@@ -5,6 +5,7 @@ use crate::frame::FrameRef;
5
5
use crate :: function:: { OptionalArg , PyFuncArgs } ;
6
6
use crate :: obj:: objstr:: PyStringRef ;
7
7
use crate :: pyobject:: { IntoPyObject , ItemProtocol , PyClassImpl , PyContext , PyObjectRef , PyResult } ;
8
+ use crate :: version;
8
9
use crate :: vm:: VirtualMachine ;
9
10
10
11
/*
@@ -160,6 +161,8 @@ pub fn make_module(vm: &VirtualMachine, module: PyObjectRef, builtins: PyObjectR
160
161
"unknown" . to_string ( )
161
162
} ;
162
163
164
+ let copyright = "Copyright (c) 2019 RustPython Team" ;
165
+
163
166
let sys_doc = "This module provides access to some objects used or maintained by the
164
167
interpreter and to functions that interact strongly with the interpreter.
165
168
@@ -229,16 +232,23 @@ setprofile() -- set the global profiling function
229
232
setrecursionlimit() -- set the max recursion depth for the interpreter
230
233
settrace() -- set the global debug tracing function
231
234
" ;
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 ( ) ;
233
236
module_names. push ( "sys" . to_string ( ) ) ;
234
237
module_names. push ( "builtins" . to_string ( ) ) ;
235
238
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
+ ) ;
236
245
let modules = ctx. new_dict ( ) ;
237
246
extend_module ! ( vm, module, {
238
247
"__name__" => ctx. new_str( String :: from( "sys" ) ) ,
239
248
"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 ,
241
250
"byteorder" => ctx. new_str( bytorder) ,
251
+ "copyright" => ctx. new_str( copyright. to_string( ) ) ,
242
252
"flags" => flags,
243
253
"getrefcount" => ctx. new_rustfunc( sys_getrefcount) ,
244
254
"getsizeof" => ctx. new_rustfunc( sys_getsizeof) ,
@@ -260,6 +270,7 @@ settrace() -- set the global debug tracing function
260
270
"path_importer_cache" => ctx. new_dict( ) ,
261
271
"pycache_prefix" => vm. get_none( ) ,
262
272
"dont_write_bytecode" => vm. new_bool( true ) ,
273
+ "version" => vm. new_str( version:: get_version( ) ) ,
263
274
} ) ;
264
275
265
276
modules. set_item ( "sys" , module. clone ( ) , vm) . unwrap ( ) ;
0 commit comments