Issue #13088: Add shared Py_hexdigits constant to format a number into base 16

This commit is contained in:
Victor Stinner 2011-10-14 02:13:11 +02:00
parent e506437b52
commit f5cff56a1b
16 changed files with 118 additions and 135 deletions

View file

@ -162,7 +162,6 @@ static PyObject *
escape_encode(PyObject *self,
PyObject *args)
{
static const char *hexdigits = "0123456789abcdef";
PyObject *str;
Py_ssize_t size;
Py_ssize_t newsize;
@ -205,8 +204,8 @@ escape_encode(PyObject *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;