Skip to content

Commit c6c4c79

Browse files
committed
shared/runtime/sys_stdio_mphal: Fix docstring for stdio.
Signed-off-by: timdechant <[email protected]>
1 parent 16b6c88 commit c6c4c79

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

shared/runtime/sys_stdio_mphal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ STATIC const sys_stdio_obj_t stdio_buffer_obj;
5454

5555
STATIC void stdio_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
5656
sys_stdio_obj_t *self = MP_OBJ_TO_PTR(self_in);
57-
mp_printf(print, "<io.StringIO %d>", self->fd);
57+
mp_printf(print, "<io.%s %d>", mp_obj_get_type_str(self_in), self->fd);
5858
}
5959

6060
STATIC mp_uint_t stdio_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) {
@@ -122,7 +122,7 @@ STATIC const mp_stream_p_t stdio_obj_stream_p = {
122122

123123
MP_DEFINE_CONST_OBJ_TYPE(
124124
stdio_obj_type,
125-
MP_QSTR_StringIO,
125+
MP_QSTR_TextIOWrapper,
126126
MP_TYPE_FLAG_ITER_IS_STREAM,
127127
print, stdio_obj_print,
128128
protocol, &stdio_obj_stream_p,

tests/basics/sys_stdio.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Test sys.std* objects.
2+
3+
import sys
4+
5+
# CPython is more verbose; no need to match exactly
6+
7+
print('TextIOWrapper' in str(sys.stdout))
8+
print('TextIOWrapper' in str(sys.stderr))
9+
print('TextIOWrapper' in str(sys.stdin))
10+
11+
print('TextIOWrapper' in str(type(sys.stdout)))
12+
print('TextIOWrapper' in str(type(sys.stderr)))
13+
print('TextIOWrapper' in str(type(sys.stdin)))
14+
15+
# # .buffer member is optional
16+
# try:
17+
# print('FileIO' in str(sys.stdout.buffer))
18+
# print('FileIO' in str(sys.stderr.buffer))
19+
# print('FileIO' in str(sys.stdin.buffer))
20+
#
21+
# print('FileIO' in str(type(sys.stdout.buffer)))
22+
# print('FileIO' in str(type(sys.stderr.buffer)))
23+
# print('FileIO' in str(type(sys.stdin.buffer)))
24+
# except AttributeError:
25+
# print("SKIP")

0 commit comments

Comments
 (0)