mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
Issue #13088: Add shared Py_hexdigits constant to format a number into base 16
This commit is contained in:
parent
e506437b52
commit
f5cff56a1b
16 changed files with 118 additions and 135 deletions
|
|
@ -850,7 +850,6 @@ bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
|
|||
static PyObject *
|
||||
bytearray_repr(PyByteArrayObject *self)
|
||||
{
|
||||
static const char *hexdigits = "0123456789abcdef";
|
||||
const char *quote_prefix = "bytearray(b";
|
||||
const char *quote_postfix = ")";
|
||||
Py_ssize_t length = Py_SIZE(self);
|
||||
|
|
@ -912,8 +911,8 @@ bytearray_repr(PyByteArrayObject *self)
|
|||
else if (c < ' ' || c >= 0x7f) {
|
||||
*p++ = '\\';
|
||||
*p++ = 'x';
|
||||
*p++ = hexdigits[(c & 0xf0) >> 4];
|
||||
*p++ = hexdigits[c & 0xf];
|
||||
*p++ = Py_hexdigits[(c & 0xf0) >> 4];
|
||||
*p++ = Py_hexdigits[c & 0xf];
|
||||
}
|
||||
else
|
||||
*p++ = c;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue