Skip to content

Commit 561578f

Browse files
authored
Merge pull request #9598 from timdechant/micropython-merge
shared/runtime/sys_stdio_mphal: Fix docstring for stdio.
2 parents b3283d2 + 01ae274 commit 561578f

File tree

5 files changed

+52
-2
lines changed

5 files changed

+52
-2
lines changed

ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ CHIP_FAMILY = samd21
99
SPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C, W25Q16JVxQ"
1111
LONGINT_IMPL = MPZ
12+
13+
CIRCUITPY_RAINBOWIO = 0

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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Test sys.std* objects.
2+
3+
import sys
4+
5+
try:
6+
sys.stdout
7+
sys.stdin
8+
sys.stderr
9+
except AttributeError:
10+
print("SKIP")
11+
raise SystemExit
12+
13+
# CPython is more verbose; no need to match exactly
14+
15+
print('TextIOWrapper' in str(sys.stdout))
16+
print('TextIOWrapper' in str(sys.stderr))
17+
print('TextIOWrapper' in str(sys.stdin))
18+
19+
print('TextIOWrapper' in str(type(sys.stdout)))
20+
print('TextIOWrapper' in str(type(sys.stderr)))
21+
print('TextIOWrapper' in str(type(sys.stdin)))

tests/basics/sys_stdio_buffer.py

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

tests/basics/sys_stdio_buffer.py.exp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
True
2+
True
3+
True
4+
True
5+
True
6+
True

0 commit comments

Comments
 (0)