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
9a90900d
Commit
9a90900d
authored
Oct 18, 2010
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PyUnicode_FromFormatV(): Fix %A format
It was not completly implemented. Add a test.
parent
0410656b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
Lib/test/test_unicode.py
Lib/test/test_unicode.py
+6
-3
Objects/unicodeobject.c
Objects/unicodeobject.c
+1
-0
No files found.
Lib/test/test_unicode.py
View file @
9a90900d
...
...
@@ -1380,20 +1380,23 @@ class UnicodeTest(string_tests.CommonTest,
self
.
assertEqual
(
"{}"
.
format
(
s
),
'__str__ overridden'
)
def
test_from_format
(
self
):
# Ensure that PyUnicode_FromFormat() raises an error for a non-ascii
# format string.
from
_testcapi
import
format_unicode
# ascii format, non-ascii argument
text
=
format_unicode
(
b'ascii
\
x7f
=%U'
,
'unicode
\
xe9
'
)
self
.
assertEqual
(
text
,
'ascii
\
x7f
=unicode
\
xe9
'
)
# non-ascii format, ascii argument
# non-ascii format, ascii argument: ensure that PyUnicode_FromFormat()
# raises an error for a non-ascii format string.
self
.
assertRaisesRegexp
(
ValueError
,
'^PyUnicode_FromFormatV
\
(
\
) expects an ASCII-encoded format '
'string, got a non-ASCII byte: 0xe9$'
,
format_unicode
,
b'unicode
\
xe9
=%s'
,
'ascii'
)
# other tests
text
=
format_unicode
(
b'%%A:%A'
,
'abc
\
xe9
\
uabcd
\
U0010ffff
'
)
self
.
assertEqual
(
text
,
r"%A:'abc\xe9\uabcd\U0010ffff'"
)
# Test PyUnicode_AsWideChar()
def
test_aswidechar
(
self
):
from
_testcapi
import
unicode_aswidechar
...
...
Objects/unicodeobject.c
View file @
9a90900d
...
...
@@ -1074,6 +1074,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
}
case
'S'
:
case
'R'
:
case
'A'
:
{
Py_UNICODE
*
ucopy
;
Py_ssize_t
usize
;
...
...
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