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
c2cf45d8
Commit
c2cf45d8
authored
May 02, 2001
by
Marc-André Lemburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for bug #417030: "print '%*s' fails for unicode string"
parent
045b2676
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
Lib/test/test_unicode.py
Lib/test/test_unicode.py
+6
-0
Objects/stringobject.c
Objects/stringobject.c
+3
-2
No files found.
Lib/test/test_unicode.py
View file @
c2cf45d8
...
...
@@ -366,6 +366,12 @@ verify('...%(foo)s...' % {u'foo':u"abc",u'def':123} == u'...abc...')
verify
(
'...%s...%s...%s...%s...'
%
(
1
,
2
,
3
,
u"abc"
)
==
u'...1...2...3...abc...'
)
verify
(
'...%%...%%s...%s...%s...%s...%s...'
%
(
1
,
2
,
3
,
u"abc"
)
==
u'...%...%s...1...2...3...abc...'
)
verify
(
'...%s...'
%
u"abc"
==
u'...abc...'
)
verify
(
'%*s'
%
(
5
,
u'abc'
,)
==
u' abc'
)
verify
(
'%*s'
%
(
-
5
,
u'abc'
,)
==
u'abc '
)
verify
(
'%*.*s'
%
(
5
,
2
,
u'abc'
,)
==
u' ab'
)
verify
(
'%*.*s'
%
(
5
,
3
,
u'abc'
,)
==
u' abc'
)
verify
(
'%i %*.*s'
%
(
10
,
5
,
3
,
u'abc'
,)
==
u'10 abc'
)
verify
(
'%i%s %*.*s'
%
(
10
,
3
,
5
,
3
,
u'abc'
,)
==
u'103 abc'
)
print
'done.'
# Test builtin codecs
...
...
Objects/stringobject.c
View file @
c2cf45d8
...
...
@@ -2781,6 +2781,7 @@ PyString_Format(PyObject *format, PyObject *args)
int
len
;
char
formatbuf
[
FORMATBUFLEN
];
/* For format{float,int,char}() */
char
*
fmt_start
=
fmt
;
int
argidx_start
=
argidx
;
fmt
++
;
if
(
*
fmt
==
'('
)
{
...
...
@@ -2934,6 +2935,7 @@ PyString_Format(PyObject *format, PyObject *args)
case
'r'
:
if
(
PyUnicode_Check
(
v
))
{
fmt
=
fmt_start
;
argidx
=
argidx_start
;
goto
unicode
;
}
if
(
c
==
's'
)
...
...
@@ -3098,8 +3100,7 @@ PyString_Format(PyObject *format, PyObject *args)
Py_DECREF
(
args
);
args_owned
=
0
;
}
/* Fiddle args right (remove the first argidx-1 arguments) */
--
argidx
;
/* Fiddle args right (remove the first argidx arguments) */
if
(
PyTuple_Check
(
orig_args
)
&&
argidx
>
0
)
{
PyObject
*
v
;
int
n
=
PyTuple_GET_SIZE
(
orig_args
)
-
argidx
;
...
...
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