summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/sys_stdio_buffer.py
diff options
context:
space:
mode:
authortimdechant <timdechant.git@gmail.com>2024-08-26 10:34:42 -0400
committerDamien George <damien@micropython.org>2024-09-06 17:00:35 +1000
commit455415b1e1199c4364e84cc31905452f7c4ec399 (patch)
tree36ae9d1a6108e60f20ef2c73f8e03af77213484a /tests/basics/sys_stdio_buffer.py
parent659113825d10bf2ae71dd215a8597451e505982d (diff)
downloadmicropython-455415b1e1199c4364e84cc31905452f7c4ec399.tar.gz
micropython-455415b1e1199c4364e84cc31905452f7c4ec399.zip
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_buffer.py')
-rw-r--r--tests/basics/sys_stdio_buffer.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/basics/sys_stdio_buffer.py b/tests/basics/sys_stdio_buffer.py
new file mode 100644
index 0000000000..ae354ec7fb
--- /dev/null
+++ b/tests/basics/sys_stdio_buffer.py
@@ -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)))