Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
acf47b80
Commit
acf47b80
authored
Oct 06, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix my last change on PyUnicode_Join(): don't process separator if len==1
parent
25a4b29c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
28 deletions
+32
-28
Objects/unicodeobject.c
Objects/unicodeobject.c
+32
-28
No files found.
Objects/unicodeobject.c
View file @
acf47b80
...
...
@@ -9145,37 +9145,41 @@ PyUnicode_Join(PyObject *separator, PyObject *seq)
/* If singleton sequence with an exact Unicode, return that. */
items
=
PySequence_Fast_ITEMS
(
fseq
);
if
(
seqlen
==
1
&&
PyUnicode_CheckExact
(
items
[
0
]))
{
res
=
items
[
0
];
Py_INCREF
(
res
);
Py_DECREF
(
fseq
);
return
res
;
}
/* Set up sep and seplen */
if
(
separator
==
NULL
)
{
/* fall back to a blank space separator */
sep
=
PyUnicode_FromOrdinal
(
' '
);
if
(
!
sep
)
goto
onError
;
maxchar
=
32
;
if
(
seqlen
==
1
)
{
if
(
PyUnicode_CheckExact
(
items
[
0
]))
{
res
=
items
[
0
];
Py_INCREF
(
res
);
Py_DECREF
(
fseq
);
return
res
;
}
sep
=
NULL
;
}
else
{
if
(
!
PyUnicode_Check
(
separator
))
{
PyErr_Format
(
PyExc_TypeError
,
"separator: expected str instance,"
" %.80s found"
,
Py_TYPE
(
separator
)
->
tp_name
);
goto
onError
;
/* Set up sep and seplen */
if
(
separator
==
NULL
)
{
/* fall back to a blank space separator */
sep
=
PyUnicode_FromOrdinal
(
' '
);
if
(
!
sep
)
goto
onError
;
maxchar
=
32
;
}
else
{
if
(
!
PyUnicode_Check
(
separator
))
{
PyErr_Format
(
PyExc_TypeError
,
"separator: expected str instance,"
" %.80s found"
,
Py_TYPE
(
separator
)
->
tp_name
);
goto
onError
;
}
if
(
PyUnicode_READY
(
separator
))
goto
onError
;
sep
=
separator
;
seplen
=
PyUnicode_GET_LENGTH
(
separator
);
maxchar
=
PyUnicode_MAX_CHAR_VALUE
(
separator
);
/* inc refcount to keep this code path symmetric with the
above case of a blank separator */
Py_INCREF
(
sep
);
}
if
(
PyUnicode_READY
(
separator
))
goto
onError
;
sep
=
separator
;
seplen
=
PyUnicode_GET_LENGTH
(
separator
);
maxchar
=
PyUnicode_MAX_CHAR_VALUE
(
separator
);
/* inc refcount to keep this code path symmetric with the
above case of a blank separator */
Py_INCREF
(
sep
);
}
/* There are at least two things to join, or else we have a subclass
...
...
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