Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shared/runtime/sys_stdio_mphal: Fix docstring for stdio. #9598

Merged
merged 6 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ CHIP_FAMILY = samd21
SPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C, W25Q16JVxQ"
LONGINT_IMPL = MPZ

CIRCUITPY_RAINBOWIO = 0
4 changes: 2 additions & 2 deletions shared/runtime/sys_stdio_mphal.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ STATIC const sys_stdio_obj_t stdio_buffer_obj;

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

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

MP_DEFINE_CONST_OBJ_TYPE(
stdio_obj_type,
MP_QSTR_StringIO,
MP_QSTR_TextIOWrapper,
MP_TYPE_FLAG_ITER_IS_STREAM,
print, stdio_obj_print,
protocol, &stdio_obj_stream_p,
Expand Down
21 changes: 21 additions & 0 deletions tests/basics/sys_stdio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Test sys.std* objects.

import sys

try:
sys.stdout
sys.stdin
sys.stderr
except AttributeError:
print("SKIP")
raise SystemExit

# CPython is more verbose; no need to match exactly

print('TextIOWrapper' in str(sys.stdout))
print('TextIOWrapper' in str(sys.stderr))
print('TextIOWrapper' in str(sys.stdin))

print('TextIOWrapper' in str(type(sys.stdout)))
print('TextIOWrapper' in str(type(sys.stderr)))
print('TextIOWrapper' in str(type(sys.stdin)))
21 changes: 21 additions & 0 deletions tests/basics/sys_stdio_buffer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Test sys.std*.buffer objects.

import sys

try:
sys.stdout.buffer
sys.stdin.buffer
sys.stderr.buffer
except AttributeError:
print("SKIP")
raise SystemExit

# CPython is more verbose; no need to match exactly

print('FileIO' in str(sys.stdout.buffer))
print('FileIO' in str(sys.stderr.buffer))
print('FileIO' in str(sys.stdin.buffer))

print('FileIO' in str(type(sys.stdout.buffer)))
print('FileIO' in str(type(sys.stderr.buffer)))
print('FileIO' in str(type(sys.stdin.buffer)))
6 changes: 6 additions & 0 deletions tests/basics/sys_stdio_buffer.py.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
True
True
True
True
True
True