Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7220f083
Commit
7220f083
authored
Sep 29, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test_codecs for Windows: check size of wchar_t, not sys.maxunicode
parent
c1c00373
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
41 deletions
+44
-41
Lib/test/test_codecs.py
Lib/test/test_codecs.py
+44
-41
No files found.
Lib/test/test_codecs.py
View file @
7220f083
...
@@ -3,6 +3,9 @@ import unittest
...
@@ -3,6 +3,9 @@ import unittest
import
codecs
import
codecs
import
locale
import
locale
import
sys
,
_testcapi
,
io
import
sys
,
_testcapi
,
io
import
ctypes
SIZEOF_WCHAR_T
=
ctypes
.
sizeof
(
ctypes
.
c_wchar
)
class
Queue
(
object
):
class
Queue
(
object
):
"""
"""
...
@@ -888,10 +891,10 @@ class PunycodeTest(unittest.TestCase):
...
@@ -888,10 +891,10 @@ class PunycodeTest(unittest.TestCase):
self
.
assertEqual
(
uni
,
puny
.
decode
(
"punycode"
))
self
.
assertEqual
(
uni
,
puny
.
decode
(
"punycode"
))
class
UnicodeInternalTest
(
unittest
.
TestCase
):
class
UnicodeInternalTest
(
unittest
.
TestCase
):
@
unittest
.
skipUnless
(
SIZEOF_WCHAR_T
==
4
,
'specific to 32-bit wchar_t'
)
def
test_bug1251300
(
self
):
def
test_bug1251300
(
self
):
# Decoding with unicode_internal used to not correctly handle "code
# Decoding with unicode_internal used to not correctly handle "code
# points" above 0x10ffff on UCS-4 builds.
# points" above 0x10ffff on UCS-4 builds.
if
sys
.
maxunicode
>
0xffff
:
ok
=
[
ok
=
[
(
b"
\
x00
\
x10
\
xff
\
xff
"
,
"
\
U0010ffff
"
),
(
b"
\
x00
\
x10
\
xff
\
xff
"
,
"
\
U0010ffff
"
),
(
b"
\
x00
\
x00
\
x01
\
x01
"
,
"
\
U00000101
"
),
(
b"
\
x00
\
x00
\
x01
\
x01
"
,
"
\
U00000101
"
),
...
@@ -914,8 +917,8 @@ class UnicodeInternalTest(unittest.TestCase):
...
@@ -914,8 +917,8 @@ class UnicodeInternalTest(unittest.TestCase):
self
.
assertRaises
(
UnicodeDecodeError
,
internal
.
decode
,
self
.
assertRaises
(
UnicodeDecodeError
,
internal
.
decode
,
"unicode_internal"
)
"unicode_internal"
)
@
unittest
.
skipUnless
(
SIZEOF_WCHAR_T
==
4
,
'specific to 32-bit wchar_t'
)
def
test_decode_error_attributes
(
self
):
def
test_decode_error_attributes
(
self
):
if
sys
.
maxunicode
>
0xffff
:
try
:
try
:
b"
\
x00
\
x00
\
x00
\
x00
\
x00
\
x11
\
x11
\
x00
"
.
decode
(
"unicode_internal"
)
b"
\
x00
\
x00
\
x00
\
x00
\
x00
\
x11
\
x11
\
x00
"
.
decode
(
"unicode_internal"
)
except
UnicodeDecodeError
as
ex
:
except
UnicodeDecodeError
as
ex
:
...
@@ -926,8 +929,8 @@ class UnicodeInternalTest(unittest.TestCase):
...
@@ -926,8 +929,8 @@ class UnicodeInternalTest(unittest.TestCase):
else
:
else
:
self
.
fail
()
self
.
fail
()
@
unittest
.
skipUnless
(
SIZEOF_WCHAR_T
==
4
,
'specific to 32-bit wchar_t'
)
def
test_decode_callback
(
self
):
def
test_decode_callback
(
self
):
if
sys
.
maxunicode
>
0xffff
:
codecs
.
register_error
(
"UnicodeInternalTest"
,
codecs
.
ignore_errors
)
codecs
.
register_error
(
"UnicodeInternalTest"
,
codecs
.
ignore_errors
)
decoder
=
codecs
.
getdecoder
(
"unicode_internal"
)
decoder
=
codecs
.
getdecoder
(
"unicode_internal"
)
ab
=
"ab"
.
encode
(
"unicode_internal"
).
decode
()
ab
=
"ab"
.
encode
(
"unicode_internal"
).
decode
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment