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
ee471d52
Commit
ee471d52
authored
Apr 15, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: make sure PyUnicode_READY() is called before unicode iteration
parent
04ff4ecc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
6 deletions
+26
-6
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+24
-6
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+2
-0
No files found.
Cython/Compiler/Optimize.py
View file @
ee471d52
...
@@ -283,14 +283,20 @@ class IterationTransform(Visitor.VisitorTransform):
...
@@ -283,14 +283,20 @@ class IterationTransform(Visitor.VisitorTransform):
),
),
reversed
=
reversed
))
reversed
=
reversed
))
PyUnicode_READY_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
c_int_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"s"
,
PyrexTypes
.
py_object_type
,
None
)
],
exception_value
=
'-1'
)
PyUnicode_GET_LENGTH_func_type
=
PyrexTypes
.
CFuncType
(
PyUnicode_GET_LENGTH_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
c_py_ssize_t_type
,
[
PyrexTypes
.
c_py_ssize_t_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"s"
,
Builtin
.
unicode
_type
,
None
)
PyrexTypes
.
CFuncTypeArg
(
"s"
,
PyrexTypes
.
py_object
_type
,
None
)
])
])
PyUnicode_KIND_func_type
=
PyrexTypes
.
CFuncType
(
PyUnicode_KIND_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
c_int_type
,
[
PyrexTypes
.
c_int_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"s"
,
Builtin
.
unicode
_type
,
None
)
PyrexTypes
.
CFuncTypeArg
(
"s"
,
PyrexTypes
.
py_object
_type
,
None
)
])
])
PyUnicode_READ_func_type
=
PyrexTypes
.
CFuncType
(
PyUnicode_READ_func_type
=
PyrexTypes
.
CFuncType
(
...
@@ -302,7 +308,7 @@ class IterationTransform(Visitor.VisitorTransform):
...
@@ -302,7 +308,7 @@ class IterationTransform(Visitor.VisitorTransform):
PyUnicode_DATA_func_type
=
PyrexTypes
.
CFuncType
(
PyUnicode_DATA_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
c_void_ptr_type
,
[
PyrexTypes
.
c_void_ptr_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"s"
,
Builtin
.
unicode
_type
,
None
)
PyrexTypes
.
CFuncTypeArg
(
"s"
,
PyrexTypes
.
py_object
_type
,
None
)
])
])
def
_transform_unicode_iteration
(
self
,
node
,
slice_node
,
reversed
=
False
):
def
_transform_unicode_iteration
(
self
,
node
,
slice_node
,
reversed
=
False
):
...
@@ -349,7 +355,7 @@ class IterationTransform(Visitor.VisitorTransform):
...
@@ -349,7 +355,7 @@ class IterationTransform(Visitor.VisitorTransform):
slice_node
.
pos
,
"__Pyx_PyUnicode_READ"
,
slice_node
.
pos
,
"__Pyx_PyUnicode_READ"
,
self
.
PyUnicode_READ_func_type
,
self
.
PyUnicode_READ_func_type
,
args
=
[
kind_temp
,
data_temp
,
counter_temp
],
args
=
[
kind_temp
,
data_temp
,
counter_temp
],
is_temp
=
0
,
is_temp
=
False
,
))
))
body
=
Nodes
.
StatListNode
(
body
=
Nodes
.
StatListNode
(
node
.
pos
,
node
.
pos
,
...
@@ -366,9 +372,21 @@ class IterationTransform(Visitor.VisitorTransform):
...
@@ -366,9 +372,21 @@ class IterationTransform(Visitor.VisitorTransform):
loop_node
=
UtilNodes
.
TempsBlockNode
(
loop_node
=
UtilNodes
.
TempsBlockNode
(
node
.
pos
,
temps
=
[
counter
],
body
=
loop_node
)
node
.
pos
,
temps
=
[
counter
],
body
=
loop_node
)
for
temp
in
(
kind_temp
,
data_temp
,
unpack_temp_node
):
# last is outermost temp
for
temp
in
(
kind_temp
,
data_temp
):
loop_node
=
UtilNodes
.
LetNode
(
temp
,
loop_node
)
loop_node
=
UtilNodes
.
LetNode
(
temp
,
loop_node
)
return
loop_node
setup_node
=
Nodes
.
ExprStatNode
(
node
.
pos
,
expr
=
ExprNodes
.
PythonCapiCallNode
(
slice_node
.
pos
,
"__Pyx_PyUnicode_READY"
,
self
.
PyUnicode_READY_func_type
,
args
=
[
unpack_temp_node
],
is_temp
=
True
,
result_is_used
=
False
,
))
return
UtilNodes
.
LetNode
(
unpack_temp_node
,
Nodes
.
StatListNode
(
node
.
pos
,
stats
=
[
setup_node
,
loop_node
]))
def
_transform_carray_iteration
(
self
,
node
,
slice_node
,
reversed
=
False
):
def
_transform_carray_iteration
(
self
,
node
,
slice_node
,
reversed
=
False
):
neg_step
=
False
neg_step
=
False
...
...
Cython/Utility/ModuleSetupCode.c
View file @
ee471d52
...
@@ -119,6 +119,7 @@
...
@@ -119,6 +119,7 @@
/* new Py3.3 unicode type (PEP 393) */
/* new Py3.3 unicode type (PEP 393) */
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
#define CYTHON_PEP393_ENABLED 1
#define CYTHON_PEP393_ENABLED 1
#define __Pyx_PyUnicode_READY(u) PyUnicode_READY(u)
#define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
#define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
...
@@ -126,6 +127,7 @@
...
@@ -126,6 +127,7 @@
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
#else
#else
#define CYTHON_PEP393_ENABLED 0
#define CYTHON_PEP393_ENABLED 0
#define __Pyx_PyUnicode_READY(u) (0)
#define __Pyx_PyUnicode_KIND(u) (0)
/* PyUnicode_WCHAR_KIND */
#define __Pyx_PyUnicode_KIND(u) (0)
/* PyUnicode_WCHAR_KIND */
#define __Pyx_PyUnicode_DATA(u) PyUnicode_AS_UNICODE(u)
#define __Pyx_PyUnicode_DATA(u) PyUnicode_AS_UNICODE(u)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
...
...
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