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
7cf0e96c
Commit
7cf0e96c
authored
Jul 28, 2007
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #1704793: Raise KeyError if unicodedata.lookup cannot
represent the result in a single character.
parent
028332d0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
Lib/test/test_unicodedata.py
Lib/test/test_unicodedata.py
+5
-1
Misc/NEWS
Misc/NEWS
+3
-0
Modules/unicodedata.c
Modules/unicodedata.c
+11
-1
No files found.
Lib/test/test_unicodedata.py
View file @
7cf0e96c
...
...
@@ -6,7 +6,7 @@
"""
#"
import
unittest
,
test
.
test_support
import
hashlib
import
hashlib
,
sys
encoding
=
'utf-8'
...
...
@@ -214,6 +214,10 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
count
+=
1
self
.
assert_
(
count
>=
10
)
# should have tested at least the ASCII digits
def
test_bug_1704793
(
self
):
if
sys
.
maxunicode
==
65535
:
self
.
assertRaises
(
KeyError
,
self
.
db
.
lookup
,
"GOTHIC LETTER FAIHU"
)
def
test_main
():
test
.
test_support
.
run_unittest
(
UnicodeMiscTest
,
...
...
Misc/NEWS
View file @
7cf0e96c
...
...
@@ -26,6 +26,9 @@ Core and builtins
Library
-------
- Bug #1704793: Raise KeyError if unicodedata.lookup cannot
represent the result in a single character.
- Change location of the package index to pypi.python.org/pypi
- Bug #1701409: Fix a segfault in printing ctypes.c_char_p and
...
...
Modules/unicodedata.c
View file @
7cf0e96c
...
...
@@ -1102,8 +1102,18 @@ unicodedata_lookup(PyObject* self, PyObject* args)
return
NULL
;
}
#ifndef Py_UNICODE_WIDE
if
(
code
>=
0x10000
)
{
/* Raise KeyError for compatibility; the possibly more
correct ValueError was not documented as a possible
exception for 2.5.x and earlier. */
PyErr_Format
(
PyExc_KeyError
,
"result %d larger than sys.maxunicode"
,
code
);
return
NULL
;
}
#endif
str
[
0
]
=
(
Py_UNICODE
)
code
;
return
PyUnicode_FromUnicode
(
str
,
1
);
return
PyUnicode_FromUnicode
(
str
,
1
);
}
/* XXX Add doc strings. */
...
...
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