From 15192a1f4cf1645b15b636d375bc7af798c96cf9 2011-10-26 20:28:27 From: Thomas Kluyver Date: 2011-10-26 20:28:27 Subject: [PATCH] Tweak test for magic_cpaste. --- diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index 3e15f01..ebcd510 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -324,10 +324,9 @@ def check_cpaste(code, should_fail=False): _ip.user_ns['code_ran'] = False src = StringIO() - try: - src.encoding = None # IPython expects stdin to have an encoding attribute - except Exception: - pass # ...but it's a read-only attribute in Python 3 + if not hasattr(src, 'encoding'): + # IPython expects stdin to have an encoding attribute + src.encoding = None src.write('\n') src.write(code) src.write('\n--\n')