diff options
author | timdechant <timdechant.git@gmail.com> | 2024-08-26 10:34:42 -0400 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-09-06 17:00:35 +1000 |
commit | 455415b1e1199c4364e84cc31905452f7c4ec399 (patch) | |
tree | 36ae9d1a6108e60f20ef2c73f8e03af77213484a /tests/basics/sys_stdio.py | |
parent | 659113825d10bf2ae71dd215a8597451e505982d (diff) |
shared/runtime/sys_stdio_mphal: Fix printed type for stdio streams.
The printed type for stdio streams indicates "FileIO", which is a binary IO
stream. Stdio is not binary by design, and its printed type should
indicate a text stream. "TextIOWrapper" suits that purpose, and is used
by VfsPosix files.
Signed-off-by: timdechant <timdechant.git@gmail.com>
Diffstat (limited to 'tests/basics/sys_stdio.py')
-rw-r--r-- | tests/basics/sys_stdio.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/basics/sys_stdio.py b/tests/basics/sys_stdio.py new file mode 100644 index 000000000..8d746b8b4 --- /dev/null +++ b/tests/basics/sys_stdio.py @@ -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))) |