diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-29 20:01:55 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-29 20:01:55 +0200 |
commit | ef17f12a393b4d7653066f34e0207ef8f46065c4 (patch) | |
tree | c0c6a3aefce219e9f8f727e67b37e80ca62e0a5e /Lib/test/test_codeccallbacks.py | |
parent | 182d90d9ee7755d19996705d13ee58447de00f32 (diff) | |
download | cpython-ef17f12a393b4d7653066f34e0207ef8f46065c4.tar.gz cpython-ef17f12a393b4d7653066f34e0207ef8f46065c4.zip |
Fix test_codeccallbacks for Windows: check size of wchar_t, not sys.maxunicode
Diffstat (limited to 'Lib/test/test_codeccallbacks.py')
-rw-r--r-- | Lib/test/test_codeccallbacks.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py index 317ae44ccf9..486f49e0873 100644 --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -2,6 +2,8 @@ import test.support, unittest import sys, codecs, html.entities, unicodedata import ctypes +SIZEOF_WCHAR_T = ctypes.sizeof(ctypes.c_wchar) + class PosReturn: # this can be used for configurable callbacks @@ -206,7 +208,7 @@ class CodecCallbackTest(unittest.TestCase): b"\x00\x00\x00\x00\x00".decode, "unicode-internal", ) - if sys.maxunicode > 0xffff: + if SIZEOF_WCHAR_T == 4: def handler_unicodeinternal(exc): if not isinstance(exc, UnicodeDecodeError): raise TypeError("don't know how to handle %r" % exc) @@ -356,7 +358,7 @@ class CodecCallbackTest(unittest.TestCase): ["ascii", "\uffffx", 0, 1, "ouch"], "'ascii' codec can't encode character '\\uffff' in position 0: ouch" ) - if sys.maxunicode > 0xffff: + if SIZEOF_WCHAR_T == 4: self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", "\U00010000x", 0, 1, "ouch"], @@ -391,7 +393,7 @@ class CodecCallbackTest(unittest.TestCase): ["g\uffffrk", 1, 2, "ouch"], "can't translate character '\\uffff' in position 1: ouch" ) - if sys.maxunicode > 0xffff: + if SIZEOF_WCHAR_T == 4: self.check_exceptionobjectargs( UnicodeTranslateError, ["g\U00010000rk", 1, 2, "ouch"], @@ -682,7 +684,7 @@ class CodecCallbackTest(unittest.TestCase): # Python/codecs.c::PyCodec_XMLCharRefReplaceErrors() # and inline implementations v = (1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000) - if sys.maxunicode>=100000: + if SIZEOF_WCHAR_T == 4: v += (100000, 500000, 1000000) s = "".join([chr(x) for x in v]) codecs.register_error("test.xmlcharrefreplace", codecs.xmlcharrefreplace_errors) |