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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
4fad8beb
Commit
4fad8beb
authored
Apr 18, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
call PyUnicode_READY() during unicode indexing to comply with C-API constraints
parent
0d3af956
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
1 deletion
+13
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+9
-0
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+3
-0
Cython/Utility/Optimize.c
Cython/Utility/Optimize.c
+1
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
4fad8beb
...
...
@@ -10011,6 +10011,9 @@ proto = '''
__Pyx_GetItemInt_Unicode_Generic(o, to_py_func(i)))
static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i) {
#if CYTHON_PEP393_ENABLED
if (unlikely(__Pyx_PyUnicode_READY(ustring) < 0)) return (Py_UCS4)-1;
#endif
const Py_ssize_t length = __Pyx_PyUnicode_GET_LENGTH(ustring);
if (likely((0 <= i) & (i < length))) {
return __Pyx_PyUnicode_READ_CHAR(ustring, i);
...
...
@@ -10029,6 +10032,12 @@ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Generic(PyObject* ustring,
uchar_string = PyObject_GetItem(ustring, j);
Py_DECREF(j);
if (!uchar_string) return (Py_UCS4)-1;
#if CYTHON_PEP393_ENABLED
if (unlikely(__Pyx_PyUnicode_READY(uchar_string) < 0)) {
Py_DECREF(uchar_string);
return (Py_UCS4)-1;
}
#endif
uchar = __Pyx_PyUnicode_READ_CHAR(uchar_string, 0);
Py_DECREF(uchar_string);
return uchar;
...
...
Cython/Utility/ModuleSetupCode.c
View file @
4fad8beb
...
...
@@ -119,11 +119,14 @@
/* new Py3.3 unicode type (PEP 393) */
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
#define CYTHON_PEP393_ENABLED 1
#define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \
0 : _PyUnicode_Ready((PyObject *)(op)))
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
#else
#define CYTHON_PEP393_ENABLED 0
#define __Pyx_PyUnicode_READY(op) (0)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
/* (k=k) => avoid unused variable warning due to macro: */
...
...
Cython/Utility/Optimize.c
View file @
4fad8beb
...
...
@@ -428,7 +428,7 @@ static CYTHON_INLINE int __Pyx_init_unicode_iteration(
static
CYTHON_INLINE
int
__Pyx_init_unicode_iteration
(
PyObject
*
ustring
,
Py_ssize_t
*
length
,
void
**
data
,
int
*
kind
)
{
#if CYTHON_PEP393_ENABLED
if
(
unlikely
(
PyUnicode_READY
(
ustring
)
<
0
))
return
-
1
;
if
(
unlikely
(
__Pyx_
PyUnicode_READY
(
ustring
)
<
0
))
return
-
1
;
*
kind
=
PyUnicode_KIND
(
ustring
);
*
length
=
PyUnicode_GET_LENGTH
(
ustring
);
*
data
=
PyUnicode_DATA
(
ustring
);
...
...
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