mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-98836: Extend PyUnicode_FromFormat() (GH-98838)
* Support for conversion specifiers o (octal) and X (uppercase hexadecimal). * Support for length modifiers j (intmax_t) and t (ptrdiff_t). * Length modifiers are now applied to all integer conversions. * Support for wchar_t C strings (%ls and %lV). * Support for variable width and precision (*). * Support for flag - (left alignment).
This commit is contained in:
parent
6ba8406cb6
commit
f3466bc040
10 changed files with 584 additions and 287 deletions
|
@ -1330,10 +1330,8 @@ _get_peer_alt_names (_sslmodulestate *state, X509 *certificate) {
|
|||
p[0], p[1], p[2], p[3]
|
||||
);
|
||||
} else if (name->d.ip->length == 16) {
|
||||
/* PyUnicode_FromFormat() does not support %X */
|
||||
unsigned char *p = name->d.ip->data;
|
||||
len = sprintf(
|
||||
buf,
|
||||
v = PyUnicode_FromFormat(
|
||||
"%X:%X:%X:%X:%X:%X:%X:%X",
|
||||
p[0] << 8 | p[1],
|
||||
p[2] << 8 | p[3],
|
||||
|
@ -1344,7 +1342,6 @@ _get_peer_alt_names (_sslmodulestate *state, X509 *certificate) {
|
|||
p[12] << 8 | p[13],
|
||||
p[14] << 8 | p[15]
|
||||
);
|
||||
v = PyUnicode_FromStringAndSize(buf, len);
|
||||
} else {
|
||||
v = PyUnicode_FromString("<invalid>");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue