mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +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
|
@ -564,7 +564,6 @@ PyBytes_AsStringAndSize(register PyObject *obj,
|
|||
PyObject *
|
||||
PyBytes_Repr(PyObject *obj, int smartquotes)
|
||||
{
|
||||
static const char *hexdigits = "0123456789abcdef";
|
||||
register PyBytesObject* op = (PyBytesObject*) obj;
|
||||
Py_ssize_t i, length = Py_SIZE(op);
|
||||
size_t newsize, squotes, dquotes;
|
||||
|
@ -620,8 +619,8 @@ PyBytes_Repr(PyObject *obj, int smartquotes)
|
|||
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