From bf19541f466fe40176c80ccfe324ef13c96bf957 Mon Sep 17 00:00:00 2001 From: stijn Date: Fri, 16 Jan 2015 13:36:18 +0100 Subject: py: Prevent segfault for operations on closed StringIO. Addresses issue #1067. --- tests/io/stringio1.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/io/stringio1.py b/tests/io/stringio1.py index 6979fe7c9..dae0187f8 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") -- cgit v1.2.3