diff -r eee959fee5f5 Lib/test/test_sys.py --- a/Lib/test/test_sys.py Sat May 07 21:13:50 2016 +0300 +++ b/Lib/test/test_sys.py Fri May 13 21:03:55 2016 +0200 @@ -10,6 +10,7 @@ import gc import sysconfig import platform +import locale # count the number of test runs, used to create unique # strings to intern in test_intern() @@ -628,6 +629,12 @@ @unittest.skipUnless(test.support.FS_NONASCII, 'requires OS support of non-ASCII encodings') def test_ioencoding_nonascii(self): + try: + with open(os.devnull, 'w') as f: + print(test.support.FS_NONASCII, file=f) + except UnicodeEncodeError: + self.skipTest('preferred encoding set to "%s"' % + locale.getpreferredencoding()) env = dict(os.environ) env["PYTHONIOENCODING"] = ""