Kaydet (Commit) a222e4cc authored tarafından Guido van Rossum's avatar Guido van Rossum

Fix the last remaining problem with test_multibytecodec.py;

the problem was writing a file in text mode instead of in binary mode.
üst 89687b9b
...@@ -51,7 +51,7 @@ class Test_MultibyteCodec(unittest.TestCase): ...@@ -51,7 +51,7 @@ class Test_MultibyteCodec(unittest.TestCase):
print('# coding:', enc, file=io.open(TESTFN, 'w')) print('# coding:', enc, file=io.open(TESTFN, 'w'))
execfile(TESTFN) execfile(TESTFN)
finally: finally:
os.unlink(TESTFN) test_support.unlink(TESTFN)
class Test_IncrementalEncoder(unittest.TestCase): class Test_IncrementalEncoder(unittest.TestCase):
...@@ -139,13 +139,18 @@ class Test_IncrementalDecoder(unittest.TestCase): ...@@ -139,13 +139,18 @@ class Test_IncrementalDecoder(unittest.TestCase):
class Test_StreamReader(unittest.TestCase): class Test_StreamReader(unittest.TestCase):
def test_bug1728403(self): def test_bug1728403(self):
try: try:
open(TESTFN, 'w').write('\xa1') f = open(TESTFN, 'wb')
try:
f.write(b'\xa1')
finally:
f.close()
f = codecs.open(TESTFN, encoding='cp949') f = codecs.open(TESTFN, encoding='cp949')
self.assertRaises(UnicodeDecodeError, f.read, 2) try:
self.assertRaises(UnicodeDecodeError, f.read, 2)
finally:
f.close()
finally: finally:
try: f.close() test_support.unlink(TESTFN)
except: pass
os.unlink(TESTFN)
class Test_StreamWriter(unittest.TestCase): class Test_StreamWriter(unittest.TestCase):
if len('\U00012345') == 2: # UCS2 if len('\U00012345') == 2: # UCS2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment