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
Kirill Smelkov
cython
Commits
6642d167
Commit
6642d167
authored
Mar 21, 2020
by
da-woods
Committed by
Stefan Behnel
Mar 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only use PyUnicode_Concat on unicode object operations (GH-3433)
parent
033e6864
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+16
-11
tests/run/test_unicode_string_tests.pxi
tests/run/test_unicode_string_tests.pxi
+8
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
6642d167
...
...
@@ -11390,19 +11390,24 @@ class AddNode(NumBinopNode):
self
,
type1
,
type2
)
def
py_operation_function
(
self
,
code
):
is_unicode_concat
=
False
if
isinstance
(
self
.
operand1
,
FormattedValueNode
)
or
isinstance
(
self
.
operand2
,
FormattedValueNode
):
is_unicode_concat
=
True
else
:
type1
,
type2
=
self
.
operand1
.
type
,
self
.
operand2
.
type
if
type1
is
unicode_type
or
type2
is
unicode_type
:
is_unicode_concat
=
type1
.
is_builtin_type
and
type2
.
is_builtin_type
if
type1
in
(
unicode_type
,
str_type
)
and
type2
in
(
unicode_type
,
str_type
):
is_unicode_concat
=
True
elif
isinstance
(
self
.
operand1
,
FormattedValueNode
)
or
isinstance
(
self
.
operand2
,
FormattedValueNode
):
# Assume that even if we don't know the second type, it's going to be a string.
is_unicode_concat
=
True
else
:
# Operation depends on the second type.
is_unicode_concat
=
False
if
is_unicode_concat
:
if
self
.
operand1
.
may_be_none
()
or
self
.
operand2
.
may_be_none
():
return
'__Pyx_PyUnicode_ConcatSafe'
else
:
return
'__Pyx_PyUnicode_Concat'
return
super
(
AddNode
,
self
).
py_operation_function
(
code
)
...
...
tests/run/test_unicode_string_tests.pxi
View file @
6642d167
...
...
@@ -993,6 +993,14 @@ class CommonTest(BaseTest):
self
.
checkequal
(
'
\
u019b
\
u1d00
\
u1d86
\
u0221
\
u1fb7
'
,
'
\
u019b
\
u1d00
\
u1d86
\
u0221
\
u1fb7
'
,
'capitalize'
)
def
test_list_concat
(
self
):
# https://github.com/cython/cython/issues/3426
y
=
[]
y
+=
'ab'
self
.
assertEqual
(
'a'
,
y
[
0
])
self
.
assertEqual
(
'b'
,
y
[
1
])
self
.
assertEqual
([
'a'
,
'b'
],
y
)
class
MixinStrUnicodeUserStringTest
:
# additional tests that only work for
...
...
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