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
00b2c86d
Commit
00b2c86d
authored
Oct 05, 2011
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix text failures when ctypes is not available
(followup to Victor's 85d11cf67aa8 and 7a50e549bd11)
parent
4637309e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
28 deletions
+39
-28
Lib/test/test_codeccallbacks.py
Lib/test/test_codeccallbacks.py
+32
-26
Lib/test/test_codecs.py
Lib/test/test_codecs.py
+7
-2
No files found.
Lib/test/test_codeccallbacks.py
View file @
00b2c86d
import
test.support
,
unittest
import
test.support
,
unittest
import
sys
,
codecs
,
html
.
entities
,
unicodedata
import
sys
,
codecs
,
html
.
entities
,
unicodedata
import
ctypes
SIZEOF_WCHAR_T
=
ctypes
.
sizeof
(
ctypes
.
c_wchar
)
try
:
import
ctypes
except
ImportError
:
ctypes
=
None
SIZEOF_WCHAR_T
=
-
1
else
:
SIZEOF_WCHAR_T
=
ctypes
.
sizeof
(
ctypes
.
c_wchar
)
class
PosReturn
:
class
PosReturn
:
# this can be used for configurable callbacks
# this can be used for configurable callbacks
...
@@ -572,33 +577,34 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -572,33 +577,34 @@ class CodecCallbackTest(unittest.TestCase):
UnicodeEncodeError
(
"ascii"
,
"
\
uffff
"
,
0
,
1
,
"ouch"
)),
UnicodeEncodeError
(
"ascii"
,
"
\
uffff
"
,
0
,
1
,
"ouch"
)),
(
"
\
\
uffff"
,
1
)
(
"
\
\
uffff"
,
1
)
)
)
if
ctypes
.
sizeof
(
ctypes
.
c_wchar
)
==
2
:
if
SIZEOF_WCHAR_T
==
2
:
len_wide
=
2
len_wide
=
2
else
:
else
:
len_wide
=
1
len_wide
=
1
self
.
assertEqual
(
if
SIZEOF_WCHAR_T
>
0
:
codecs
.
backslashreplace_errors
(
self
.
assertEqual
(
UnicodeEncodeError
(
"ascii"
,
"
\
U00010000
"
,
codecs
.
backslashreplace_errors
(
0
,
len_wide
,
"ouch"
)),
UnicodeEncodeError
(
"ascii"
,
"
\
U00010000
"
,
(
"
\
\
U00010000"
,
len_wide
)
0
,
len_wide
,
"ouch"
)),
)
(
"
\
\
U00010000"
,
len_wide
)
self
.
assertEqual
(
)
codecs
.
backslashreplace_errors
(
self
.
assertEqual
(
UnicodeEncodeError
(
"ascii"
,
"
\
U0010ffff
"
,
codecs
.
backslashreplace_errors
(
0
,
len_wide
,
"ouch"
)),
UnicodeEncodeError
(
"ascii"
,
"
\
U0010ffff
"
,
(
"
\
\
U0010ffff"
,
len_wide
)
0
,
len_wide
,
"ouch"
)),
)
(
"
\
\
U0010ffff"
,
len_wide
)
# Lone surrogates (regardless of unicode width)
)
self
.
assertEqual
(
# Lone surrogates (regardless of unicode width)
codecs
.
backslashreplace_errors
(
self
.
assertEqual
(
UnicodeEncodeError
(
"ascii"
,
"
\
ud800
"
,
0
,
1
,
"ouch"
)),
codecs
.
backslashreplace_errors
(
(
"
\
\
ud800"
,
1
)
UnicodeEncodeError
(
"ascii"
,
"
\
ud800
"
,
0
,
1
,
"ouch"
)),
)
(
"
\
\
ud800"
,
1
)
self
.
assertEqual
(
)
codecs
.
backslashreplace_errors
(
self
.
assertEqual
(
UnicodeEncodeError
(
"ascii"
,
"
\
udfff
"
,
0
,
1
,
"ouch"
)),
codecs
.
backslashreplace_errors
(
(
"
\
\
udfff"
,
1
)
UnicodeEncodeError
(
"ascii"
,
"
\
udfff
"
,
0
,
1
,
"ouch"
)),
)
(
"
\
\
udfff"
,
1
)
)
def
test_badhandlerresults
(
self
):
def
test_badhandlerresults
(
self
):
results
=
(
42
,
"foo"
,
(
1
,
2
,
3
),
(
"foo"
,
1
,
3
),
(
"foo"
,
None
),
(
"foo"
,),
(
"foo"
,
1
,
3
),
(
"foo"
,
None
),
(
"foo"
,)
)
results
=
(
42
,
"foo"
,
(
1
,
2
,
3
),
(
"foo"
,
1
,
3
),
(
"foo"
,
None
),
(
"foo"
,),
(
"foo"
,
1
,
3
),
(
"foo"
,
None
),
(
"foo"
,)
)
...
...
Lib/test/test_codecs.py
View file @
00b2c86d
...
@@ -3,9 +3,14 @@ import unittest
...
@@ -3,9 +3,14 @@ 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
)
try
:
import
ctypes
except
ImportError
:
ctypes
=
None
SIZEOF_WCHAR_T
=
-
1
else
:
SIZEOF_WCHAR_T
=
ctypes
.
sizeof
(
ctypes
.
c_wchar
)
class
Queue
(
object
):
class
Queue
(
object
):
"""
"""
...
...
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