summaryrefslogtreecommitdiffstatshomepage
path: root/tests/io/stringio1.py
diff options
context:
space:
mode:
authorstijn <stinos@zoho.com>2015-01-16 13:36:18 +0100
committerDamien George <damien.p.george@gmail.com>2015-01-20 23:50:43 +0000
commitbf19541f466fe40176c80ccfe324ef13c96bf957 (patch)
tree88aa42e85788c44d5412a5aac3d4384a7cd1a41a /tests/io/stringio1.py
parent0ab3fc3805282cc733bdf7a5970ec37e3160beee (diff)
downloadmicropython-bf19541f466fe40176c80ccfe324ef13c96bf957.tar.gz
micropython-bf19541f466fe40176c80ccfe324ef13c96bf957.zip
py: Prevent segfault for operations on closed StringIO.
Addresses issue #1067.
Diffstat (limited to 'tests/io/stringio1.py')
-rw-r--r--tests/io/stringio1.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/io/stringio1.py b/tests/io/stringio1.py
index 6979fe7c9d..dae0187f88 100644
--- a/tests/io/stringio1.py
+++ b/tests/io/stringio1.py
@@ -28,3 +28,14 @@ print(a.getvalue())
a = io.StringIO()
a.write("foo")
print(a.read())
+
+a = io.StringIO()
+a.close()
+for f in [a.read, a.getvalue, lambda:a.write("")]:
+ # CPython throws for operations on closed I/O, micropython makes
+ # the underlying string empty unless MICROPY_CPYTHON_COMPAT defined
+ try:
+ f()
+ print("ValueError")
+ except ValueError:
+ print("ValueError")