Skip to content

Commit 7807dc3

Browse files
Merge pull request RustPython#388 from veera83372/sys-doc
Added __doc__ for sys module
2 parents 3c25c14 + cf2d075 commit 7807dc3

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ __pycache__
77
.repl_history.txt
88
.vscode
99
wasm-pack.log
10+
.idea/
File renamed without changes.

vm/src/sysmodule.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,75 @@ pub fn mk_module(ctx: &PyContext) -> PyObjectRef {
5353
let modules = ctx.new_dict();
5454

5555
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+
";
56125
let sys_mod = ctx.new_module(&sys_name, ctx.new_scope(None));
57126

58127
ctx.set_item(&modules, sys_name, sys_mod.clone());
@@ -65,6 +134,7 @@ pub fn mk_module(ctx: &PyContext) -> PyObjectRef {
65134
ctx.set_item(&sys_mod, "path", path);
66135
ctx.set_item(&sys_mod, "ps1", ctx.new_str(">>>>> ".to_string()));
67136
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()));
68138
ctx.set_item(&sys_mod, "_getframe", ctx.new_rustfunc(getframe));
69139

70140
sys_mod

0 commit comments

Comments
 (0)