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
74a080f4
Commit
74a080f4
authored
Aug 23, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adapted __Pyx_PyObject_AsPy_UNICODE() to PEP 393
parent
0b27c6a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
25 deletions
+36
-25
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+36
-25
No files found.
Cython/Compiler/PyrexTypes.py
View file @
74a080f4
...
@@ -1053,31 +1053,42 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject*);
...
@@ -1053,31 +1053,42 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject*);
'''
,
'''
,
impl
=
'''
impl
=
'''
static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) {
static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) {
static long maxval = 0;
long ival;
long ival;
#ifdef CYTHON_PEP393_ENABLED
if (PyUnicode_Check(x)) {
const long maxval = 1114111;
if (unlikely(PyUnicode_GET_SIZE(x) != 1)) {
#else
PyErr_Format(PyExc_ValueError,
static long maxval = 0;
"only single character unicode strings can be converted to Py_UNICODE, "
#endif
"got length %"PY_FORMAT_SIZE_T"d", PyUnicode_GET_SIZE(x));
if (PyUnicode_Check(x)) {
return (Py_UNICODE)-1;
if (unlikely(__Pyx_PyUnicode_GET_LENGTH(x) != 1)) {
}
PyErr_Format(PyExc_ValueError,
return PyUnicode_AS_UNICODE(x)[0];
"only single character unicode strings can be converted to Py_UNICODE, "
}
"got length %"PY_FORMAT_SIZE_T"d", __Pyx_PyUnicode_GET_LENGTH(x));
if (unlikely(!maxval))
return (Py_UNICODE)-1;
maxval = (long)PyUnicode_GetMax();
}
ival = __Pyx_PyInt_AsLong(x);
#ifdef CYTHON_PEP393_ENABLED
if (unlikely(ival < 0)) {
ival = PyUnicode_READ_CHAR(x, 0);
if (!PyErr_Occurred())
#else
PyErr_SetString(PyExc_OverflowError,
return PyUnicode_AS_UNICODE(x)[0];
"cannot convert negative value to Py_UNICODE");
#endif
return (Py_UNICODE)-1;
} else {
} else if (unlikely(ival > maxval)) {
#ifndef CYTHON_PEP393_ENABLED
PyErr_SetString(PyExc_OverflowError,
if (unlikely(!maxval))
"value too large to convert to Py_UNICODE");
maxval = (long)PyUnicode_GetMax();
return (Py_UNICODE)-1;
#endif
}
ival = __Pyx_PyInt_AsLong(x);
return (Py_UNICODE)ival;
}
if (unlikely(ival < 0)) {
if (!PyErr_Occurred())
PyErr_SetString(PyExc_OverflowError,
"cannot convert negative value to Py_UNICODE");
return (Py_UNICODE)-1;
} else if (unlikely(ival > maxval)) {
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to Py_UNICODE");
return (Py_UNICODE)-1;
}
return (Py_UNICODE)ival;
}
}
'''
)
'''
)
...
...
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