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
f1e0b3f6
Commit
f1e0b3f6
authored
Jul 28, 2007
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #1704793: Return UTF-16 pair if unicodedata.lookup cannot
represent the result in a single character.
parent
f25e35b9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
Lib/test/test_unicodedata.py
Lib/test/test_unicodedata.py
+3
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/unicodedata.c
Modules/unicodedata.c
+11
-16
No files found.
Lib/test/test_unicodedata.py
View file @
f1e0b3f6
...
...
@@ -214,6 +214,9 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
count
+=
1
self
.
assert_
(
count
>=
10
)
# should have tested at least the ASCII digits
def
test_bug_1704793
(
self
):
self
.
assertEquals
(
self
.
db
.
lookup
(
"GOTHIC LETTER FAIHU"
),
u'
\
U00010346
'
)
def
test_main
():
test
.
test_support
.
run_unittest
(
UnicodeMiscTest
,
...
...
Misc/NEWS
View file @
f1e0b3f6
...
...
@@ -238,6 +238,9 @@ Core and builtins
Library
-------
- Bug #1704793: Return UTF-16 pair if unicodedata.lookup cannot
represent the result in a single character.
- Bug #978833: Close https sockets by releasing the _ssl object.
- Change location of the package index to pypi.python.org/pypi
...
...
Modules/unicodedata.c
View file @
f1e0b3f6
...
...
@@ -1077,8 +1077,7 @@ static PyObject *
unicodedata_lookup
(
PyObject
*
self
,
PyObject
*
args
)
{
Py_UCS4
code
;
Py_UNICODE
str
[
1
];
char
errbuf
[
256
];
Py_UNICODE
str
[
2
];
char
*
name
;
int
namelen
;
...
...
@@ -1086,22 +1085,18 @@ unicodedata_lookup(PyObject* self, PyObject* args)
return
NULL
;
if
(
!
_getcode
(
self
,
name
,
namelen
,
&
code
))
{
/* XXX(nnorwitz): why are we allocating for the error msg?
Why not always use snprintf? */
char
fmt
[]
=
"undefined character name '%s'"
;
char
*
buf
=
PyMem_MALLOC
(
sizeof
(
fmt
)
+
namelen
);
if
(
buf
)
sprintf
(
buf
,
fmt
,
name
);
else
{
buf
=
errbuf
;
PyOS_snprintf
(
buf
,
sizeof
(
errbuf
),
fmt
,
name
);
}
PyErr_SetString
(
PyExc_KeyError
,
buf
);
if
(
buf
!=
errbuf
)
PyMem_FREE
(
buf
);
PyErr_Format
(
PyExc_KeyError
,
"undefined character name '%s'"
,
name
);
return
NULL
;
}
#ifndef Py_UNICODE_WIDE
if
(
code
>=
0x10000
)
{
str
[
0
]
=
0xd800
+
((
code
-
0x10000
)
>>
10
);
str
[
1
]
=
0xdc00
+
((
code
-
0x10000
)
&
0x3ff
);
return
PyUnicode_FromUnicode
(
str
,
2
);
}
#endif
str
[
0
]
=
(
Py_UNICODE
)
code
;
return
PyUnicode_FromUnicode
(
str
,
1
);
}
...
...
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