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
1f05a3b7
Commit
1f05a3b7
authored
May 10, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the array tests. Only a minor change to the C code was required.
parent
bce56a6c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
17 deletions
+15
-17
Lib/test/test_array.py
Lib/test/test_array.py
+12
-16
Modules/arraymodule.c
Modules/arraymodule.c
+3
-1
No files found.
Lib/test/test_array.py
View file @
1f05a3b7
...
...
@@ -755,32 +755,28 @@ tests.append(CharacterTest)
if
test_support
.
have_unicode
:
class
UnicodeTest
(
StringTest
):
typecode
=
'u'
example
=
str
(
r'\x01\u263a\x00\ufeff'
,
'unicode-escape'
)
smallerexample
=
str
(
r'\x01\u263a\x00\ufefe'
,
'unicode-escape'
)
biggerexample
=
str
(
r'\x01\u263a\x01\ufeff'
,
'unicode-escape'
)
example
=
'
\
x01
\
u263a
\
x00
\
ufeff
'
smallerexample
=
'
\
x01
\
u263a
\
x00
\
ufefe
'
biggerexample
=
'
\
x01
\
u263a
\
x01
\
ufeff
'
outside
=
str
(
'
\
x33
'
)
minitemsize
=
2
def
test_unicode
(
self
):
self
.
assertRaises
(
TypeError
,
array
.
array
,
'b'
,
str
(
'foo'
,
'ascii'
)
)
self
.
assertRaises
(
TypeError
,
array
.
array
,
'b'
,
'foo'
)
a
=
array
.
array
(
'u'
,
str
(
r'\xa0\xc2\u1234'
,
'unicode-escape'
)
)
a
.
fromunicode
(
str
(
' '
,
'ascii'
)
)
a
.
fromunicode
(
str
(
''
,
'ascii'
)
)
a
.
fromunicode
(
str
(
''
,
'ascii'
)
)
a
.
fromunicode
(
str
(
r'\x11abc\xff\u1234'
,
'unicode-escape'
)
)
a
=
array
.
array
(
'u'
,
'
\
xa0
\
xc2
\
u1234
'
)
a
.
fromunicode
(
' '
)
a
.
fromunicode
(
''
)
a
.
fromunicode
(
''
)
a
.
fromunicode
(
'
\
x11
abc
\
xff
\
u1234
'
)
s
=
a
.
tounicode
()
self
.
assertEqual
(
s
,
str
(
r'\xa0\xc2\u1234 \x11abc\xff\u1234'
,
'unicode-escape'
)
)
self
.
assertEqual
(
s
,
'
\
xa0
\
xc2
\
u1234
\
x11
abc
\
xff
\
u1234
'
)
s
=
str
(
r'\x00="\'a\\b\x80\xff\u0000\u0001\u1234'
,
'unicode-escape'
)
s
=
'
\
x00
="
\
'
a
\
\
b
\
x80
\
xff
\
u0000
\
u0001
\
u1234
'
a
=
array
.
array
(
'u'
,
s
)
self
.
assertEqual
(
repr
(
a
),
r"""array('u', u'\x00="\'a\\b\x80\xff\x00\x01\u1234')"""
)
"array('u', '
\
\
x00=
\
"
\
\
'a
\
\
\
\
b
\
\
x80
\
\
xff
\
\
x00
\
\
x01
\
\
u1234')"
)
self
.
assertRaises
(
TypeError
,
a
.
fromunicode
)
...
...
Modules/arraymodule.c
View file @
1f05a3b7
...
...
@@ -104,7 +104,9 @@ in bounds; that's the responsibility of the caller.
static
PyObject
*
c_getitem
(
arrayobject
*
ap
,
Py_ssize_t
i
)
{
return
PyString_FromStringAndSize
(
&
((
char
*
)
ap
->
ob_item
)[
i
],
1
);
Py_UNICODE
buf
[
1
];
buf
[
0
]
=
((
unsigned
char
*
)
ap
->
ob_item
)[
i
];
return
PyUnicode_FromUnicode
(
buf
,
1
);
}
static
int
...
...
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