From 4c98edc58829d77e110f388cc8887df767a318a6 Mon Sep 17 00:00:00 2001 From: Johnny Robeson Date: Tue, 21 Jun 2016 23:44:24 -0400 Subject: [PATCH] check for encoding attr before set in test_helper This makes it work equivalently in py2 and py3 --- test/helper.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/helper.py b/test/helper.py index 9335a7d6b..067509221 100644 --- a/test/helper.py +++ b/test/helper.py @@ -89,7 +89,8 @@ def control_stdin(input=None): """ org = sys.stdin sys.stdin = StringIO(input) - sys.stdin.encoding = 'utf8' + if hasattr(sys.stdin, 'encoding'): + sys.stdin.encoding = 'utf8' try: yield sys.stdin finally: @@ -108,7 +109,8 @@ def capture_stdout(): """ org = sys.stdout sys.stdout = capture = StringIO() - sys.stdout.encoding = 'utf8' + if not hasattr(sys.stdout, 'encoding'): + sys.stdout.encoding = 'utf8' try: yield sys.stdout finally: