@@ -53,6 +53,75 @@ pub fn mk_module(ctx: &PyContext) -> PyObjectRef {
53
53
let modules = ctx. new_dict ( ) ;
54
54
55
55
let sys_name = "sys" ;
56
+ let sys_doc = "This module provides access to some objects used or maintained by the
57
+ interpreter and to functions that interact strongly with the interpreter.
58
+
59
+ Dynamic objects:
60
+
61
+ argv -- command line arguments; argv[0] is the script pathname if known
62
+ path -- module search path; path[0] is the script directory, else ''
63
+ modules -- dictionary of loaded modules
64
+
65
+ displayhook -- called to show results in an interactive session
66
+ excepthook -- called to handle any uncaught exception other than SystemExit
67
+ To customize printing in an interactive session or to install a custom
68
+ top-level exception handler, assign other functions to replace these.
69
+
70
+ stdin -- standard input file object; used by input()
71
+ stdout -- standard output file object; used by print()
72
+ stderr -- standard error object; used for error messages
73
+ By assigning other file objects (or objects that behave like files)
74
+ to these, it is possible to redirect all of the interpreter's I/O.
75
+
76
+ last_type -- type of last uncaught exception
77
+ last_value -- value of last uncaught exception
78
+ last_traceback -- traceback of last uncaught exception
79
+ These three are only available in an interactive session after a
80
+ traceback has been printed.
81
+
82
+ Static objects:
83
+
84
+ builtin_module_names -- tuple of module names built into this interpreter
85
+ copyright -- copyright notice pertaining to this interpreter
86
+ exec_prefix -- prefix used to find the machine-specific Python library
87
+ executable -- absolute path of the executable binary of the Python interpreter
88
+ float_info -- a struct sequence with information about the float implementation.
89
+ float_repr_style -- string indicating the style of repr() output for floats
90
+ hash_info -- a struct sequence with information about the hash algorithm.
91
+ hexversion -- version information encoded as a single integer
92
+ implementation -- Python implementation information.
93
+ int_info -- a struct sequence with information about the int implementation.
94
+ maxsize -- the largest supported length of containers.
95
+ maxunicode -- the value of the largest Unicode code point
96
+ platform -- platform identifier
97
+ prefix -- prefix used to find the Python library
98
+ thread_info -- a struct sequence with information about the thread implementation.
99
+ version -- the version of this interpreter as a string
100
+ version_info -- version information as a named tuple
101
+ __stdin__ -- the original stdin; don't touch!
102
+ __stdout__ -- the original stdout; don't touch!
103
+ __stderr__ -- the original stderr; don't touch!
104
+ __displayhook__ -- the original displayhook; don't touch!
105
+ __excepthook__ -- the original excepthook; don't touch!
106
+
107
+ Functions:
108
+
109
+ displayhook() -- print an object to the screen, and save it in builtins._
110
+ excepthook() -- print an exception and its traceback to sys.stderr
111
+ exc_info() -- return thread-safe information about the current exception
112
+ exit() -- exit the interpreter by raising SystemExit
113
+ getdlopenflags() -- returns flags to be used for dlopen() calls
114
+ getprofile() -- get the global profiling function
115
+ getrefcount() -- return the reference count for an object (plus one :-)
116
+ getrecursionlimit() -- return the max recursion depth for the interpreter
117
+ getsizeof() -- return the size of an object in bytes
118
+ gettrace() -- get the global debug tracing function
119
+ setcheckinterval() -- control how often the interpreter checks for events
120
+ setdlopenflags() -- set the flags to be used for dlopen() calls
121
+ setprofile() -- set the global profiling function
122
+ setrecursionlimit() -- set the max recursion depth for the interpreter
123
+ settrace() -- set the global debug tracing function
124
+ " ;
56
125
let sys_mod = ctx. new_module ( & sys_name, ctx. new_scope ( None ) ) ;
57
126
58
127
ctx. set_item ( & modules, sys_name, sys_mod. clone ( ) ) ;
@@ -65,6 +134,7 @@ pub fn mk_module(ctx: &PyContext) -> PyObjectRef {
65
134
ctx. set_item ( & sys_mod, "path" , path) ;
66
135
ctx. set_item ( & sys_mod, "ps1" , ctx. new_str ( ">>>>> " . to_string ( ) ) ) ;
67
136
ctx. set_item ( & sys_mod, "ps2" , ctx. new_str ( "..... " . to_string ( ) ) ) ;
137
+ ctx. set_item ( & sys_mod, "__doc__" , ctx. new_str ( sys_doc. to_string ( ) ) ) ;
68
138
ctx. set_item ( & sys_mod, "_getframe" , ctx. new_rustfunc ( getframe) ) ;
69
139
70
140
sys_mod
0 commit comments