Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
79f7d7f3
Commit
79f7d7f3
authored
Jan 31, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support surrogate pair to Py_UCS4 coercion only in 16 bit Unicode builds
parent
1ba2eaea
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+5
-2
tests/run/py_ucs4_type.pyx
tests/run/py_ucs4_type.pyx
+2
-2
No files found.
Cython/Compiler/PyrexTypes.py
View file @
79f7d7f3
...
...
@@ -958,7 +958,9 @@ static CYTHON_INLINE Py_UCS4 __Pyx_PyObject_AsPy_UCS4(PyObject* x) {
if (PyUnicode_Check(x)) {
if (likely(PyUnicode_GET_SIZE(x) == 1)) {
return PyUnicode_AS_UNICODE(x)[0];
} else if (PyUnicode_GET_SIZE(x) == 2) {
}
#if Py_UNICODE_SIZE == 2
else if (PyUnicode_GET_SIZE(x) == 2) {
Py_UCS4 high_val = PyUnicode_AS_UNICODE(x)[0];
if (high_val >= 0xD800 && high_val <= 0xDBFF) {
Py_UCS4 low_val = PyUnicode_AS_UNICODE(x)[1];
...
...
@@ -967,8 +969,9 @@ static CYTHON_INLINE Py_UCS4 __Pyx_PyObject_AsPy_UCS4(PyObject* x) {
}
}
}
#endif
PyErr_Format(PyExc_ValueError,
"only single character unicode strings
or surrogate pairs
can be converted to Py_UCS4, got length "
"only single character unicode strings can be converted to Py_UCS4, got length "
#if PY_VERSION_HEX < 0x02050000
"%d",
#else
...
...
tests/run/py_ucs4_type.pyx
View file @
79f7d7f3
...
...
@@ -68,13 +68,13 @@ def unicode_ordinal(Py_UCS4 i):
>>> unicode_ordinal(u0[:0])
Traceback (most recent call last):
...
ValueError: only single character unicode strings
or surrogate pairs
can be converted to Py_UCS4, got length 0
ValueError: only single character unicode strings can be converted to Py_UCS4, got length 0
More than one character:
>>> unicode_ordinal(u0+u1)
Traceback (most recent call last):
...
ValueError: only single character unicode strings
or surrogate pairs
can be converted to Py_UCS4, got length 2
ValueError: only single character unicode strings can be converted to Py_UCS4, got length 2
"""
return
i
...
...
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