mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +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
|
@ -1339,8 +1339,6 @@ setbdaddr(const char *name, bdaddr_t *bdaddr)
|
|||
static PyObject *
|
||||
makebdaddr(bdaddr_t *bdaddr)
|
||||
{
|
||||
char buf[(6 * 2) + 5 + 1];
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
int i;
|
||||
unsigned int octets[6];
|
||||
|
@ -1349,16 +1347,14 @@ makebdaddr(bdaddr_t *bdaddr)
|
|||
octets[i] = ((*bdaddr) >> (8 * i)) & 0xFF;
|
||||
}
|
||||
|
||||
sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
return PyUnicode_FromFormat("%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
octets[5], octets[4], octets[3],
|
||||
octets[2], octets[1], octets[0]);
|
||||
#else
|
||||
sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
return PyUnicode_FromFormat("%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
bdaddr->b[5], bdaddr->b[4], bdaddr->b[3],
|
||||
bdaddr->b[2], bdaddr->b[1], bdaddr->b[0]);
|
||||
#endif
|
||||
|
||||
return PyUnicode_FromString(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue