From e409b979509af36bbd9ee8ebbc85d805062e2e95 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 12 Jul 2007 09:25:21 +0000 Subject: [PATCH] Make this a pure-ASCII file. This used to have a Latin-1 coding and contain several string literals using non-ASCII characters. Because of the pain of displaying those characters, it's better to use \xXX escapes for these instead of typing the accented characters. Apologies if I missed something; it didn't look like there was anything that depended on this file being encoded in Latin-1 or containing non-ASCII characters. --- Lib/ctypes/test/test_unicode.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Lib/ctypes/test/test_unicode.py b/Lib/ctypes/test/test_unicode.py index f8e6f09fe9b..3a89d8d156f 100644 --- a/Lib/ctypes/test/test_unicode.py +++ b/Lib/ctypes/test/test_unicode.py @@ -1,4 +1,3 @@ -# coding: latin-1 import unittest import ctypes @@ -27,14 +26,14 @@ else: self.failUnlessEqual(wcslen("ab\u2070"), 3) # string args are converted self.failUnlessEqual(wcslen("abc"), 3) - self.failUnlessRaises(ctypes.ArgumentError, wcslen, "abä") + self.failUnlessRaises(ctypes.ArgumentError, wcslen, "ab\xe4") def test_ascii_replace(self): ctypes.set_conversion_mode("ascii", "replace") self.failUnlessEqual(wcslen("abc"), 3) self.failUnlessEqual(wcslen("ab\u2070"), 3) self.failUnlessEqual(wcslen("abc"), 3) - self.failUnlessEqual(wcslen("abä"), 3) + self.failUnlessEqual(wcslen("ab\xe4"), 3) def test_ascii_ignore(self): ctypes.set_conversion_mode("ascii", "ignore") @@ -42,14 +41,14 @@ else: self.failUnlessEqual(wcslen("ab\u2070"), 3) # ignore error mode skips non-ascii characters self.failUnlessEqual(wcslen("abc"), 3) - self.failUnlessEqual(wcslen("äöüß"), 0) + self.failUnlessEqual(wcslen("\xe4\xf6\xfc\xdf"), 0) def test_latin1_strict(self): ctypes.set_conversion_mode("latin-1", "strict") self.failUnlessEqual(wcslen("abc"), 3) self.failUnlessEqual(wcslen("ab\u2070"), 3) self.failUnlessEqual(wcslen("abc"), 3) - self.failUnlessEqual(wcslen("äöüß"), 4) + self.failUnlessEqual(wcslen("\xe4\xf6\xfc\xdf"), 4) def test_buffers(self): ctypes.set_conversion_mode("ascii", "strict") @@ -57,11 +56,11 @@ else: self.failUnlessEqual(len(buf), 3+1) ctypes.set_conversion_mode("ascii", "replace") - buf = ctypes.create_unicode_buffer("abäöü") + buf = ctypes.create_unicode_buffer("ab\xe4\xf6\xfc") self.failUnlessEqual(buf[:], "ab\uFFFD\uFFFD\uFFFD\0") ctypes.set_conversion_mode("ascii", "ignore") - buf = ctypes.create_unicode_buffer("abäöü") + buf = ctypes.create_unicode_buffer("ab\xe4\xf6\xfc") # is that correct? not sure. But with 'ignore', you get what you pay for.. self.failUnlessEqual(buf[:], "ab\0\0\0\0") @@ -83,19 +82,19 @@ else: ctypes.set_conversion_mode("ascii", "strict") self.failUnlessEqual(func("abc"), "abc") self.failUnlessEqual(func("abc"), "abc") - self.assertRaises(ctypes.ArgumentError, func, "abä") + self.assertRaises(ctypes.ArgumentError, func, "ab\xe4") def test_ascii_ignore(self): ctypes.set_conversion_mode("ascii", "ignore") self.failUnlessEqual(func("abc"), "abc") self.failUnlessEqual(func("abc"), "abc") - self.failUnlessEqual(func("äöüß"), "") + self.failUnlessEqual(func("\xe4\xf6\xfc\xdf"), "") def test_ascii_replace(self): ctypes.set_conversion_mode("ascii", "replace") self.failUnlessEqual(func("abc"), "abc") self.failUnlessEqual(func("abc"), "abc") - self.failUnlessEqual(func("äöüß"), "????") + self.failUnlessEqual(func("\xe4\xf6\xfc\xdf"), "????") def test_buffers(self): ctypes.set_conversion_mode("ascii", "strict") @@ -103,11 +102,11 @@ else: self.failUnlessEqual(len(buf), 3+1) ctypes.set_conversion_mode("ascii", "replace") - buf = ctypes.create_string_buffer("abäöü") + buf = ctypes.create_string_buffer("ab\xe4\xf6\xfc") self.failUnlessEqual(buf[:], "ab???\0") ctypes.set_conversion_mode("ascii", "ignore") - buf = ctypes.create_string_buffer("abäöü") + buf = ctypes.create_string_buffer("ab\xe4\xf6\xfc") # is that correct? not sure. But with 'ignore', you get what you pay for.. self.failUnlessEqual(buf[:], "ab\0\0\0\0")